Compare commits

..

3 Commits

Author SHA1 Message Date
Peng-YM
e93332048e fix: Occasional crashed when performing migration 2022-08-10 00:28:46 +08:00
Peng-YM
4dcb9ae79e feat: Include cron-sync-artifact in Stash configuration 2022-08-09 22:42:13 +08:00
Peng-YM
6ea3575101 fix: Rename subscription and collection will break artifacts 2022-08-09 22:28:45 +08:00
8 changed files with 57 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -1,5 +1,5 @@
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 $ from '@/core/app';
import { RequestInvalidError, ResourceNotFoundError } from '@/restful/errors';
@@ -67,6 +67,21 @@ function updateCollection(req, res) {
...collection,
};
$.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);
$.write(allCols, COLLECTIONS_KEY);
success(res, newCol);

View File

@@ -5,7 +5,7 @@ import {
RequestInvalidError,
} from './errors';
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 { success, failed } from './response';
import $ from '@/core/app';
@@ -137,14 +137,28 @@ function updateSubscription(req, res) {
$.info(`正在更新订阅: ${name}`);
// allow users to update the subscription name
if (name !== sub.name) {
// we need to find out all collections refer to this name
const allCols = $.read(COLLECTIONS_KEY);
// update all collections refer to this name
const allCols = $.read(COLLECTIONS_KEY) || [];
for (const collection of allCols) {
const idx = collection.subscriptions.indexOf(name);
if (idx !== -1) {
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);
$.write(allSubs, SUBS_KEY);

View File

@@ -81,7 +81,8 @@ function doMigrationV2() {
useless: 'DEFAULT',
},
};
processes.forEach((p) => {
for (const p of processes) {
if (!p.type) continue;
if (p.type === 'Useless Filter') {
quickSettingOperator.args.useless = 'ENABLED';
} else if (p.type === 'Set Property Operator') {
@@ -120,7 +121,7 @@ function doMigrationV2() {
} else {
newProcesses.push(p);
}
});
}
newProcesses.unshift(quickSettingOperator);
item.process = newProcesses;
}

File diff suppressed because one or more lines are too long

View File

@@ -10,7 +10,18 @@ http:
type: request
require-body: true
timeout: 120
cron:
script:
- name: cron-sync-artifacts
cron: "0 0 * * *"
timeout: 120
script-providers:
sub-store:
url: https://github.com/sub-store-org/Sub-Store/releases/latest/download/sub-store.min.js
interval: 86400
cron-sync-artifacts:
url: https://github.com/sub-store-org/Sub-Store/releases/latest/download/cron-sync-artifacts.min.js
interval: 86400