feat: 更新资源时确保名称正确

This commit is contained in:
xream committed 2026-01-13 10:27:11 +08:00
1 parent 8a4063d44e
commit d23b640c64
5 files changed
+10 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.20.82",
"version": "2.20.83",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+6 -4
View File
@@ -160,14 +160,16 @@ function createArtifact(req, res) {
}
function updateArtifact(req, res) {
let artifact = req.body;
const allArtifacts = $.read(ARTIFACTS_KEY);
let oldName = req.params.name;
const artifact = findByName(allArtifacts, oldName);
if (artifact) {
$.info(`正在更新远程配置:${artifact.name}`);
const oldArtifact = findByName(allArtifacts, oldName);
if (oldArtifact) {
if (!artifact.name) artifact.name = oldArtifact.name;
$.info(`正在更新远程配置:${oldArtifact.name}`);
const newArtifact = {
...oldArtifact,
...artifact,
...req.body,
};
if (!validateArtifactName(newArtifact.name)) {
failed(
+1
View File
@@ -87,6 +87,7 @@ function updateCollection(req, res) {
const allCols = $.read(COLLECTIONS_KEY);
const oldCol = findByName(allCols, name);
if (oldCol) {
if (!collection.name) collection.name = oldCol.name;
const newCol = {
...oldCol,
...collection,
+1
View File
@@ -267,6 +267,7 @@ function updateFile(req, res) {
const allFiles = $.read(FILES_KEY);
const oldFile = findByName(allFiles, name);
if (oldFile) {
if (!file.name) file.name = oldFile.name;
const newFile = {
...oldFile,
...file,
+1
View File
@@ -298,6 +298,7 @@ function updateSubscription(req, res) {
const allSubs = $.read(SUBS_KEY);
const oldSub = findByName(allSubs, name);
if (oldSub) {
if (!sub.name) sub.name = oldSub.name;
const newSub = {
...oldSub,
...sub,