mirror of
https://github.com/silvanocerza/github-gitless-sync.git
synced 2026-07-22 05:41:36 +00:00
Fix first sync marked as done on failure
This commit is contained in:
parent
be547d8691
commit
b2f3db6050
2 changed files with 15 additions and 10 deletions
16
src/main.ts
16
src/main.ts
|
|
@ -152,9 +152,19 @@ export default class GitHubSyncPlugin extends Plugin {
|
|||
return;
|
||||
}
|
||||
if (this.settings.firstSync) {
|
||||
await this.syncManager.firstSync();
|
||||
this.settings.firstSync = false;
|
||||
this.saveSettings();
|
||||
const notice = new Notice("Syncing...");
|
||||
try {
|
||||
await this.syncManager.firstSync();
|
||||
this.settings.firstSync = false;
|
||||
this.saveSettings();
|
||||
// Shown only if sync doesn't fail
|
||||
new Notice("Sync successful", 5000);
|
||||
} catch (err) {
|
||||
// Show the error to the user, it's not automatically dismissed to make sure
|
||||
// the user sees it.
|
||||
new Notice(`Error syncing. ${err}`);
|
||||
}
|
||||
notice.hide();
|
||||
} else {
|
||||
await this.syncManager.sync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,19 +95,14 @@ export default class SyncManager {
|
|||
return;
|
||||
}
|
||||
|
||||
const notice = new Notice("Syncing...");
|
||||
this.syncing = true;
|
||||
try {
|
||||
await this.firstSyncImpl();
|
||||
// Shown only if sync doesn't fail
|
||||
new Notice("Sync successful", 5000);
|
||||
} catch (err) {
|
||||
// Show the error to the user, it's not automatically dismissed to make sure
|
||||
// the user sees it.
|
||||
new Notice(`Error syncing. ${err}`);
|
||||
this.syncing = false;
|
||||
throw err;
|
||||
}
|
||||
this.syncing = false;
|
||||
notice.hide();
|
||||
}
|
||||
|
||||
private async firstSyncImpl() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue