镜像自地址
https://github.com/JGZYES/ParlzPackageManger.git
已同步 2026-09-11 08:52:45 +08:00
fix: correct download error message + fall back to /dists for legacy /packages base
- msg.err.download-failed now reads generic '下载 %s 失败' (was wrongly '下载语言包...'), so a failed .pdm download no longer claims it's a language pack. Synced zh/en packs. - registry lookup (install_from_registry + registry_fetch) now also tries the /dists subpath when a mirror base ends with .../mirror/packages, so a stale mirror.ini keeps working after the mirror was reformed to dists/+files/.
这个提交包含在:
+1
-1
@@ -58,7 +58,7 @@ static const char *kBuiltinZh =
|
||||
"\"msg.path-exists\":\"PATH 已包含 PMM 目录\",\"msg.err.registry-not-found\":\"找不到软件包 '%s'\","
|
||||
"\"msg.pmm-self-replaced\":\"pmm 已更新到 %s\",\"msg.pmm-self-hint\":\"无法覆盖 %s(需 root/管理员);新版本在 %s。请将其加入 PATH 并在当前 shell 运行 hash -r\","
|
||||
"\"msg.err.usage\":\"用法\",\"msg.err.unknown-cmd\":\"未知命令 '%s' (试试 'pmm help')\","
|
||||
"\"msg.err.download-failed\":\"下载语言包 %s 失败\",\"msg.err.invalid-locale\":\"无效语言 %s\","
|
||||
"\"msg.err.download-failed\":\"下载 %s 失败\",\"msg.err.invalid-locale\":\"无效语言 %s\","
|
||||
"\"msg.err.not-found\":\"找不到软件包 '%s'\",\"msg.err.failed-install\":\"安装 %s 失败\",\"msg.err.conflict\":\"无法安装 %s:与已装的 %s 冲突\","
|
||||
"\"msg.err.no-registry-mirror\":\"没有配置注册表镜像\",\"msg.err.cannot-write\":\"无法写入 %s\","
|
||||
"\"desc.install\":\"安装\",\"desc.remove\":\"卸载\",\"desc.update\":\"刷新索引\","
|
||||
|
||||
+22
-10
@@ -814,16 +814,28 @@ int install_from_registry(const char *name, const char *spec, const char *mirror
|
||||
char *body = NULL;
|
||||
char *used_base = NULL;
|
||||
for (int i = 0; i < nb; i++) {
|
||||
snprintf(url, sizeof(url), "%s/%s.json", bases[i], name);
|
||||
pmm_info("%s", pmm_tr_fmt("msg.looking-up", name, bases[i]));
|
||||
body = http_get(url, &status);
|
||||
if (getenv("PMM_DEBUG")) fprintf(stderr, "[reg] %s -> body=%s status=%d\n",
|
||||
bases[i], body ? "set" : "NULL", status);
|
||||
/* accept any body that isn't an explicit not-found/server error; some
|
||||
* curl builds don't emit the status marker the way we expect, so a
|
||||
* non-NULL body with an indeterminate status should still be parsed */
|
||||
if (body && status != 404 && status != 403 && status != 503) { used_base = bases[i]; break; }
|
||||
free(body); body = NULL;
|
||||
char used = 0;
|
||||
/* layout migration: an old .../mirror/packages base also falls back to
|
||||
* .../mirror/dists, so stale mirror.ini keeps working after the reform. */
|
||||
char distsbase[2048];
|
||||
snprintf(distsbase, sizeof(distsbase), "%s", bases[i]);
|
||||
size_t dbl = strlen(distsbase);
|
||||
static const char *pkgsuf = "/packages";
|
||||
size_t dpl = strlen(pkgsuf);
|
||||
int isold = (dbl >= dpl && strcmp(distsbase + dbl - dpl, pkgsuf) == 0);
|
||||
if (isold) snprintf(distsbase + dbl - dpl, sizeof(distsbase) - (dbl - dpl), "/dists");
|
||||
|
||||
for (int attempt = 0; attempt < (isold ? 2 : 1); attempt++) {
|
||||
const char *use = (attempt == 0) ? bases[i] : distsbase;
|
||||
snprintf(url, sizeof(url), "%s/%s.json", use, name);
|
||||
pmm_info("%s", pmm_tr_fmt("msg.looking-up", name, use));
|
||||
body = http_get(url, &status);
|
||||
if (getenv("PMM_DEBUG")) fprintf(stderr, "[reg] %s -> body=%s status=%d\n",
|
||||
use, body ? "set" : "NULL", status);
|
||||
if (body && status != 404 && status != 403 && status != 503) { used_base = bases[i]; used = 1; break; }
|
||||
free(body); body = NULL;
|
||||
}
|
||||
if (used) break;
|
||||
}
|
||||
if (!body) {
|
||||
pmm_error("%s", pmm_tr_fmt("msg.err.registry-not-found", name));
|
||||
|
||||
+18
-4
@@ -197,10 +197,24 @@ static char *registry_fetch(const char *rel, int *outstatus) {
|
||||
bases[nb++] = ml->items[i].registry;
|
||||
char url[2048]; int status = 0; char *body = NULL;
|
||||
for (int i = 0; i < nb; i++) {
|
||||
snprintf(url, sizeof(url), "%s/%s", bases[i], rel);
|
||||
body = http_get(url, &status);
|
||||
if (body && status != 404 && status != 403 && status != 503) break;
|
||||
free(body); body = NULL;
|
||||
/* layout migration: an old .../mirror/packages base also falls back to
|
||||
* .../mirror/dists, so a stale mirror.ini keeps working after the reform. */
|
||||
char distsbase[2048];
|
||||
snprintf(distsbase, sizeof(distsbase), "%s", bases[i]);
|
||||
size_t dbl = strlen(distsbase);
|
||||
static const char *pkgsuf = "/packages";
|
||||
size_t dpl = strlen(pkgsuf);
|
||||
int isold = (dbl >= dpl && strcmp(distsbase + dbl - dpl, pkgsuf) == 0);
|
||||
if (isold) snprintf(distsbase + dbl - dpl, sizeof(distsbase) - (dbl - dpl), "/dists");
|
||||
|
||||
for (int attempt = 0; attempt < (isold ? 2 : 1); attempt++) {
|
||||
const char *use = (attempt == 0) ? bases[i] : distsbase;
|
||||
snprintf(url, sizeof(url), "%s/%s", use, rel);
|
||||
body = http_get(url, &status);
|
||||
if (body && status != 404 && status != 403 && status != 503) break;
|
||||
free(body); body = NULL;
|
||||
}
|
||||
if (body) break;
|
||||
}
|
||||
mirrors_free(ml);
|
||||
if (outstatus) *outstatus = status;
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
"msg.err.cannot-read": "cannot read %s",
|
||||
"msg.err.cannot-open": "cannot open file: %s",
|
||||
"msg.err.invalid-locale": "invalid language pack: %s",
|
||||
"msg.err.download-failed": "failed to download language pack %s",
|
||||
"msg.err.download-failed": "failed to download %s",
|
||||
"msg.err.no-registry-mirror": "no registry mirror configured. Add to ~/.pmm/mirror.ini",
|
||||
"msg.err.no-mirror": "no mirrors configured (use: pmm mirror add)",
|
||||
"msg.err.no-mirror-file": "no mirror file",
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
"msg.err.cannot-read": "无法读取 %s",
|
||||
"msg.err.cannot-open": "无法打开文件: %s",
|
||||
"msg.err.invalid-locale": "无效的语言包: %s",
|
||||
"msg.err.download-failed": "下载语言包 %s 失败",
|
||||
"msg.err.download-failed": "下载 %s 失败",
|
||||
"msg.err.no-registry-mirror": "没有配置注册表镜像。请添加到 ~/.pmm/mirror.ini",
|
||||
"msg.err.no-mirror": "没有配置镜像源(使用: pmm mirror add)",
|
||||
"msg.err.no-mirror-file": "没有镜像配置文件",
|
||||
|
||||
在新工单中引用
屏蔽一个用户