mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-09-12 11:53:12 +08:00
fix: Sync time is updated even if upload failed
This commit is contained in:
parent
2ee515dc23
commit
b1d811e4c5
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",
|
||||
"version": "2.8.2",
|
||||
"version": "2.8.3",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -104,16 +104,26 @@ async function gistBackup(req, res) {
|
||||
try {
|
||||
let content;
|
||||
const settings = $.read(SETTINGS_KEY);
|
||||
const updated = settings.syncTime;
|
||||
switch (action) {
|
||||
case 'upload':
|
||||
// update syncTime.
|
||||
// update syncTime
|
||||
settings.syncTime = new Date().getTime();
|
||||
$.write(settings, SETTINGS_KEY);
|
||||
content = $.read('#sub-store');
|
||||
if ($.env.isNode)
|
||||
content = JSON.stringify($.cache, null, ` `);
|
||||
$.info(`上传备份中...`);
|
||||
await gist.upload({ [GIST_BACKUP_FILE_NAME]: { content } });
|
||||
try {
|
||||
await gist.upload({
|
||||
[GIST_BACKUP_FILE_NAME]: { content },
|
||||
});
|
||||
} catch (err) {
|
||||
// restore syncTime if upload failed
|
||||
settings.syncTime = updated;
|
||||
$.write(settings, SETTINGS_KEY);
|
||||
throw err;
|
||||
}
|
||||
break;
|
||||
case 'download':
|
||||
$.info(`还原备份中...`);
|
||||
|
@ -62,8 +62,10 @@ async function updateArtifactStore() {
|
||||
|
||||
try {
|
||||
const gistId = await manager.locate();
|
||||
settings.artifactStore = `https://gist.github.com/${githubUser}/${gistId}`;
|
||||
$.write(settings, SETTINGS_KEY);
|
||||
if (gistId !== -1) {
|
||||
settings.artifactStore = `https://gist.github.com/${githubUser}/${gistId}`;
|
||||
$.write(settings, SETTINGS_KEY);
|
||||
}
|
||||
} catch (err) {
|
||||
$.error('Failed to fetch artifact store for User: ' + githubUser);
|
||||
}
|
||||
|
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