chore: 增加上传同步配置的详细日志

This commit is contained in:
xream 2024-03-16 02:47:01 +08:00
parent 6ec8c29f6a
commit a1b86e26a2
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
4 changed files with 40 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.14.257", "version": "2.14.258",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -128,10 +128,19 @@ async function doSync() {
files.map((item) => [item.path, item]), files.map((item) => [item.path, item]),
); );
} }
const url = files[encodeURIComponent(artifact.name)]?.raw_url; const raw_url =
artifact.url = isGitLab files[encodeURIComponent(artifact.name)]?.raw_url;
? url const new_url = isGitLab
: url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1'); ? raw_url
: raw_url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1');
$.info(
`上传配置完成\n文件列表: ${Object.keys(files).join(
', ',
)}\n当前文件: ${encodeURIComponent(
artifact.name,
)}\n响应返回的原始链接: ${raw_url}\n处理完的新链接: ${new_url}`,
);
artifact.url = new_url;
} }
} }

View File

@ -79,8 +79,7 @@ async function downloadSubscription(req, res) {
if ( if (
sub.source !== 'local' || sub.source !== 'local' ||
['localFirst', 'remoteFirst'].includes(sub.mergeSources) || ['localFirst', 'remoteFirst'].includes(sub.mergeSources)
url
) { ) {
try { try {
url = `${url || sub.url}` url = `${url || sub.url}`

View File

@ -563,10 +563,19 @@ async function syncArtifacts() {
files.map((item) => [item.path, item]), files.map((item) => [item.path, item]),
); );
} }
const url = files[encodeURIComponent(artifact.name)]?.raw_url; const raw_url =
artifact.url = isGitLab files[encodeURIComponent(artifact.name)]?.raw_url;
? url const new_url = isGitLab
: url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1'); ? raw_url
: raw_url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1');
$.info(
`上传配置完成\n文件列表: ${Object.keys(files).join(
', ',
)}\n当前文件: ${encodeURIComponent(
artifact.name,
)}\n响应返回的原始链接: ${raw_url}\n处理完的新链接: ${new_url}`,
);
artifact.url = new_url;
} }
} }
@ -660,10 +669,18 @@ async function syncArtifact(req, res) {
isGitLab = true; isGitLab = true;
files = Object.fromEntries(files.map((item) => [item.path, item])); files = Object.fromEntries(files.map((item) => [item.path, item]));
} }
const url = files[encodeURIComponent(artifact.name)]?.raw_url; const raw_url = files[encodeURIComponent(artifact.name)]?.raw_url;
artifact.url = isGitLab const new_url = isGitLab
? url ? raw_url
: url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1'); : raw_url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1');
$.info(
`上传配置完成\n文件列表: ${Object.keys(files).join(
', ',
)}\n当前文件: ${encodeURIComponent(
artifact.name,
)}\n响应返回的原始链接: ${raw_url}\n处理完的新链接: ${new_url}`,
);
artifact.url = new_url;
$.write(allArtifacts, ARTIFACTS_KEY); $.write(allArtifacts, ARTIFACTS_KEY);
success(res, artifact); success(res, artifact);
} catch (err) { } catch (err) {