diff --git a/src/service/github.service.ts b/src/service/github.service.ts index 36da432b..4ba9637c 100644 --- a/src/service/github.service.ts +++ b/src/service/github.service.ts @@ -145,7 +145,7 @@ export class GitHubService { public async IsGistNewer( GIST: string, - localLastUpload: Date + localLastDownload: Date ): Promise { const gist = await this.ReadGist(GIST); if (!gist) { @@ -155,10 +155,10 @@ export class GitHubService { try { gistCloudSetting = JSON.parse(gist.data.files.cloudSettings.content); const gistLastUpload = new Date(gistCloudSetting.lastUpload); - if (!localLastUpload) { + if (!localLastDownload) { return false; } - return gistLastUpload >= localLastUpload; + return gistLastUpload > localLastDownload; } catch (err) { return false; } diff --git a/src/sync.ts b/src/sync.ts index 71a03fc8..045aac1a 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -258,7 +258,7 @@ export class Sync { if (syncSetting.gist != null && syncSetting.gist !== "") { const gistNewer = await github.IsGistNewer( syncSetting.gist, - new Date(customSettings.lastUpload) + new Date(customSettings.lastDownload) ); if (gistNewer) { if ( @@ -284,7 +284,7 @@ export class Sync { } else { vscode.window.setStatusBarMessage( localize("cmd.updateSettings.info.uploadCanceled"), - 3 + 3000 ); return; } @@ -293,6 +293,7 @@ export class Sync { } customSettings.lastUpload = dateNow; + customSettings.lastDownload = dateNow; let gistObj = await github.ReadGist(syncSetting.gist); if (!gistObj) { @@ -327,17 +328,17 @@ export class Sync { if ( !allSettingFiles.some(fileToUpload => { - if (fileToUpload.fileName === "cloudSettings") { + if (fileToUpload.gistName === "cloudSettings") { return false; } - if (!gistObj.data.files[fileToUpload.fileName]) { + if (!gistObj.data.files[fileToUpload.gistName]) { return true; } if ( - gistObj.data.files[fileToUpload.fileName].content !== + gistObj.data.files[fileToUpload.gistName].content !== fileToUpload.content ) { - console.info(`Sync: file ${fileToUpload.fileName} has changed`); + console.info(`Sync: file ${fileToUpload.gistName} has changed`); return true; } }) @@ -366,7 +367,7 @@ export class Sync { } else { vscode.window.setStatusBarMessage( localize("cmd.updateSettings.info.uploadCanceled"), - 3 + 3000 ); return; }