mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-09-12 16:13:14 +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",
|
"name": "sub-store",
|
||||||
"version": "2.8.2",
|
"version": "2.8.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": {
|
||||||
|
@ -104,16 +104,26 @@ async function gistBackup(req, res) {
|
|||||||
try {
|
try {
|
||||||
let content;
|
let content;
|
||||||
const settings = $.read(SETTINGS_KEY);
|
const settings = $.read(SETTINGS_KEY);
|
||||||
|
const updated = settings.syncTime;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'upload':
|
case 'upload':
|
||||||
// update syncTime.
|
// update syncTime
|
||||||
settings.syncTime = new Date().getTime();
|
settings.syncTime = new Date().getTime();
|
||||||
$.write(settings, SETTINGS_KEY);
|
$.write(settings, SETTINGS_KEY);
|
||||||
content = $.read('#sub-store');
|
content = $.read('#sub-store');
|
||||||
if ($.env.isNode)
|
if ($.env.isNode)
|
||||||
content = JSON.stringify($.cache, null, ` `);
|
content = JSON.stringify($.cache, null, ` `);
|
||||||
$.info(`上传备份中...`);
|
$.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;
|
break;
|
||||||
case 'download':
|
case 'download':
|
||||||
$.info(`还原备份中...`);
|
$.info(`还原备份中...`);
|
||||||
|
@ -62,8 +62,10 @@ async function updateArtifactStore() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const gistId = await manager.locate();
|
const gistId = await manager.locate();
|
||||||
settings.artifactStore = `https://gist.github.com/${githubUser}/${gistId}`;
|
if (gistId !== -1) {
|
||||||
$.write(settings, SETTINGS_KEY);
|
settings.artifactStore = `https://gist.github.com/${githubUser}/${gistId}`;
|
||||||
|
$.write(settings, SETTINGS_KEY);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
$.error('Failed to fetch artifact store for User: ' + githubUser);
|
$.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