From a1b86e26a2f7d0829cf198704869d90d05365905 Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 16 Mar 2024 02:47:01 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=85=8D=E7=BD=AE=E7=9A=84=E8=AF=A6=E7=BB=86?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/products/cron-sync-artifacts.js | 17 ++++++++--- backend/src/restful/download.js | 3 +- backend/src/restful/sync.js | 33 ++++++++++++++++----- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/backend/package.json b/backend/package.json index 363c8f9..0d3aed2 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.257", + "version": "2.14.258", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/products/cron-sync-artifacts.js b/backend/src/products/cron-sync-artifacts.js index f4f8c0d..598dbce 100644 --- a/backend/src/products/cron-sync-artifacts.js +++ b/backend/src/products/cron-sync-artifacts.js @@ -128,10 +128,19 @@ async function doSync() { files.map((item) => [item.path, item]), ); } - const url = files[encodeURIComponent(artifact.name)]?.raw_url; - artifact.url = isGitLab - ? url - : url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1'); + const raw_url = + files[encodeURIComponent(artifact.name)]?.raw_url; + const new_url = isGitLab + ? 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; } } diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index a5a6b0e..a6897f3 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -79,8 +79,7 @@ async function downloadSubscription(req, res) { if ( sub.source !== 'local' || - ['localFirst', 'remoteFirst'].includes(sub.mergeSources) || - url + ['localFirst', 'remoteFirst'].includes(sub.mergeSources) ) { try { url = `${url || sub.url}` diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index e462c5e..18e68aa 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -563,10 +563,19 @@ async function syncArtifacts() { files.map((item) => [item.path, item]), ); } - const url = files[encodeURIComponent(artifact.name)]?.raw_url; - artifact.url = isGitLab - ? url - : url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1'); + const raw_url = + files[encodeURIComponent(artifact.name)]?.raw_url; + const new_url = isGitLab + ? 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; files = Object.fromEntries(files.map((item) => [item.path, item])); } - const url = files[encodeURIComponent(artifact.name)]?.raw_url; - artifact.url = isGitLab - ? url - : url?.replace(/\/raw\/[^/]*\/(.*)/, '/raw/$1'); + const raw_url = files[encodeURIComponent(artifact.name)]?.raw_url; + const new_url = isGitLab + ? 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; $.write(allArtifacts, ARTIFACTS_KEY); success(res, artifact); } catch (err) {