mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-13 18:46:01 +08:00
fix: Rename subscription and collection will break artifacts
This commit is contained in:
parent
26820ea892
commit
6ea3575101
6
backend/dist/cron-sync-artifacts.min.js
vendored
6
backend/dist/cron-sync-artifacts.min.js
vendored
File diff suppressed because one or more lines are too long
6
backend/dist/sub-store-parser.loon.min.js
vendored
6
backend/dist/sub-store-parser.loon.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.12.2",
|
"version": "2.12.3",
|
||||||
"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": {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
import { COLLECTIONS_KEY } from '@/constants';
|
import { COLLECTIONS_KEY, ARTIFACTS_KEY } from '@/constants';
|
||||||
import { failed, success } from '@/restful/response';
|
import { failed, success } from '@/restful/response';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
import { RequestInvalidError, ResourceNotFoundError } from '@/restful/errors';
|
import { RequestInvalidError, ResourceNotFoundError } from '@/restful/errors';
|
||||||
@ -67,6 +67,21 @@ function updateCollection(req, res) {
|
|||||||
...collection,
|
...collection,
|
||||||
};
|
};
|
||||||
$.info(`正在更新组合订阅:${name}...`);
|
$.info(`正在更新组合订阅:${name}...`);
|
||||||
|
|
||||||
|
if (name !== newCol.name) {
|
||||||
|
// update all artifacts referring this collection
|
||||||
|
const allArtifacts = $.read(ARTIFACTS_KEY) || [];
|
||||||
|
for (const artifact of allArtifacts) {
|
||||||
|
if (
|
||||||
|
artifact.type === 'collection' &&
|
||||||
|
artifact.source === oldCol.name
|
||||||
|
) {
|
||||||
|
artifact.source = newCol.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
updateByName(allCols, name, newCol);
|
updateByName(allCols, name, newCol);
|
||||||
$.write(allCols, COLLECTIONS_KEY);
|
$.write(allCols, COLLECTIONS_KEY);
|
||||||
success(res, newCol);
|
success(res, newCol);
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
RequestInvalidError,
|
RequestInvalidError,
|
||||||
} from './errors';
|
} from './errors';
|
||||||
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
import { deleteByName, findByName, updateByName } from '@/utils/database';
|
||||||
import { SUBS_KEY, COLLECTIONS_KEY } from '@/constants';
|
import { SUBS_KEY, COLLECTIONS_KEY, ARTIFACTS_KEY } from '@/constants';
|
||||||
import { getFlowHeaders } from '@/utils/flow';
|
import { getFlowHeaders } from '@/utils/flow';
|
||||||
import { success, failed } from './response';
|
import { success, failed } from './response';
|
||||||
import $ from '@/core/app';
|
import $ from '@/core/app';
|
||||||
@ -137,14 +137,28 @@ function updateSubscription(req, res) {
|
|||||||
$.info(`正在更新订阅: ${name}`);
|
$.info(`正在更新订阅: ${name}`);
|
||||||
// allow users to update the subscription name
|
// allow users to update the subscription name
|
||||||
if (name !== sub.name) {
|
if (name !== sub.name) {
|
||||||
// we need to find out all collections refer to this name
|
// update all collections refer to this name
|
||||||
const allCols = $.read(COLLECTIONS_KEY);
|
const allCols = $.read(COLLECTIONS_KEY) || [];
|
||||||
for (const collection of allCols) {
|
for (const collection of allCols) {
|
||||||
const idx = collection.subscriptions.indexOf(name);
|
const idx = collection.subscriptions.indexOf(name);
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
collection.subscriptions[idx] = sub.name;
|
collection.subscriptions[idx] = sub.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update all artifacts referring this subscription
|
||||||
|
const allArtifacts = $.read(ARTIFACTS_KEY) || [];
|
||||||
|
for (const artifact of allArtifacts) {
|
||||||
|
if (
|
||||||
|
artifact.type === 'subscription' &&
|
||||||
|
artifact.source == name
|
||||||
|
) {
|
||||||
|
artifact.source = sub.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$.write(allCols, COLLECTIONS_KEY);
|
||||||
|
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||||
}
|
}
|
||||||
updateByName(allSubs, name, newSub);
|
updateByName(allSubs, name, newSub);
|
||||||
$.write(allSubs, SUBS_KEY);
|
$.write(allSubs, SUBS_KEY);
|
||||||
|
6
backend/sub-store.min.js
vendored
6
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user