mirror of
https://github.com/itsPLK/ps5-payload-manager.git
synced 2026-10-19 02:19:53 -05:00
fix: migrate legacy official repository payloads to payloads_v2.json layout
This commit is contained in:
1 parent
9270ee02fe
commit
0803b69a7d
6 files changed
+33
-5
No files matched your search
@@ -1,11 +1,17 @@
|
||||
import { compareVersions, slug } from './versions.js';
|
||||
import { isSystemPayload } from './helpers.js';
|
||||
|
||||
export const OFFICIAL_REPOSITORY_URL = 'https://itsplk.github.io/ps5-payloads-mirror/payloads.json';
|
||||
export const OFFICIAL_REPOSITORY_URL = 'https://itsplk.github.io/ps5-payloads-mirror/payloads_v2.json';
|
||||
export const LEGACY_OFFICIAL_REPOSITORY_URL = 'https://itsplk.github.io/ps5-payloads-mirror/payloads.json';
|
||||
|
||||
export function isOfficialRepoUrl(url) {
|
||||
const norm = normalizeUrl(url);
|
||||
return norm === OFFICIAL_REPOSITORY_URL || norm === LEGACY_OFFICIAL_REPOSITORY_URL;
|
||||
}
|
||||
|
||||
export function isOfficialSelfUpdate(payload, srcUrl) {
|
||||
return (payload?.id || slug(payload?.name || payload?.filename)) === 'pldmgr' &&
|
||||
normalizeUrl(srcUrl) === OFFICIAL_REPOSITORY_URL;
|
||||
isOfficialRepoUrl(srcUrl);
|
||||
}
|
||||
|
||||
export function isRepositoryPayloadVisible(payload, srcUrl) {
|
||||
@@ -166,15 +172,20 @@ export function getPayloadStatus({ payload, srcUrl, items = [], sources = [], mu
|
||||
? items.filter((item) => item && item.kind === 'repo')
|
||||
: [];
|
||||
|
||||
const isOfficialSrc = isOfficialRepoUrl(normSrcUrl);
|
||||
const installedSlot =
|
||||
repoItems.find(
|
||||
(item) =>
|
||||
normalizeUrl(item.source_url) === normSrcUrl && item.id === targetId
|
||||
item.id === targetId &&
|
||||
(normalizeUrl(item.source_url) === normSrcUrl ||
|
||||
(isOfficialSrc && isOfficialRepoUrl(item.source_url)))
|
||||
) || null;
|
||||
|
||||
const otherSlots = repoItems.filter(
|
||||
(item) =>
|
||||
item.id === targetId && normalizeUrl(item.source_url) !== normSrcUrl
|
||||
item.id === targetId &&
|
||||
normalizeUrl(item.source_url) !== normSrcUrl &&
|
||||
!(isOfficialSrc && isOfficialRepoUrl(item.source_url))
|
||||
);
|
||||
|
||||
if (!installedSlot) {
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
#define PAYLOADS_STORAGE_DIR "/data/pldmgr/payloads"
|
||||
#define REPOSITORY_SOURCE_URL \
|
||||
"https://itsplk.github.io/ps5-payloads-mirror/payloads_v2.json"
|
||||
#define LEGACY_REPOSITORY_SOURCE_URL \
|
||||
"https://itsplk.github.io/ps5-payloads-mirror/payloads.json"
|
||||
#define REPOSITORY_REFRESH_INTERVAL_SEC 10800
|
||||
|
||||
/* Logging (implementation in log_server.c) */
|
||||
|
||||
@@ -17,6 +17,7 @@ void pldmgr_utils_get_payload_folder_name(const char *filename, char *out_buf, s
|
||||
int pldmgr_json_escape(const char *src, char *dst, size_t dst_size);
|
||||
int is_pldmgr_name(const char *name);
|
||||
int is_pldmgr_official_source(const char *url);
|
||||
int is_legacy_official_repo_url(const char *url);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+5
-1
@@ -497,7 +497,8 @@ static int slot_read_meta_unlocked(const char *slot_dir, SlotMeta *out_meta) {
|
||||
json_extract_string(json, end, "source_url", out_meta->source_url, sizeof(out_meta->source_url));
|
||||
json_extract_string(json, end, "source_name", out_meta->source_name, sizeof(out_meta->source_name));
|
||||
if (out_meta->source_name[0] == '\0' && out_meta->source_url[0] != '\0') {
|
||||
if (strcmp(out_meta->source_url, REPOSITORY_SOURCE_URL) == 0) {
|
||||
if (strcmp(out_meta->source_url, REPOSITORY_SOURCE_URL) == 0 ||
|
||||
is_legacy_official_repo_url(out_meta->source_url)) {
|
||||
strncpy(out_meta->source_name, "Official Repository", sizeof(out_meta->source_name) - 1);
|
||||
}
|
||||
}
|
||||
@@ -1026,6 +1027,9 @@ int slot_migrate_legacy(void) {
|
||||
if (strcmp(inst_src, "repository") == 0) {
|
||||
strcpy(new_meta.kind, SLOT_KIND_REPO);
|
||||
const char *surl = inst_detail[0] ? inst_detail : REPOSITORY_SOURCE_URL;
|
||||
if (is_legacy_official_repo_url(surl)) {
|
||||
surl = REPOSITORY_SOURCE_URL;
|
||||
}
|
||||
strncpy(new_meta.source_url, surl, sizeof(new_meta.source_url) - 1);
|
||||
if (strcmp(new_meta.source_url, REPOSITORY_SOURCE_URL) == 0) {
|
||||
strncpy(new_meta.source_name, "Official Repository", sizeof(new_meta.source_name) - 1);
|
||||
|
||||
@@ -48,6 +48,9 @@ static int source_item(const char *start, const char *end, void *context) {
|
||||
json_extract_string(start, end, "url", entry.url, sizeof(entry.url)) ||
|
||||
!entry.id[0] || !entry.name[0] || !entry.url[0]) return -1;
|
||||
if (!strcmp(entry.id, "default")) return 0;
|
||||
if (is_legacy_official_repo_url(entry.url)) {
|
||||
snprintf(entry.url, sizeof(entry.url), "%s", REPOSITORY_SOURCE_URL);
|
||||
}
|
||||
if (parse->count >= MAX_SOURCES) return -1;
|
||||
for (int i = 0; i < parse->count; i++)
|
||||
if (!strcmp(parse->entries[i].id, entry.id)) return -1;
|
||||
|
||||
@@ -168,3 +168,10 @@ int is_pldmgr_official_source(const char *url) {
|
||||
return n == strlen(REPOSITORY_SOURCE_URL) && !strncmp(url, REPOSITORY_SOURCE_URL, n);
|
||||
}
|
||||
|
||||
int is_legacy_official_repo_url(const char *url) {
|
||||
if (!url) return 0;
|
||||
size_t n = strlen(url);
|
||||
while (n && url[n - 1] == '/') n--;
|
||||
return n == strlen(LEGACY_REPOSITORY_SOURCE_URL) && !strncmp(url, LEGACY_REPOSITORY_SOURCE_URL, n);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user