From be547d8691e185f6b20cd9d8d917951c71506eab Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Sun, 20 Apr 2025 11:12:17 +0200 Subject: [PATCH] Fix trying to sync deleted files on first sync --- src/sync-manager.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sync-manager.ts b/src/sync-manager.ts index aef5235..ffef47b 100644 --- a/src/sync-manager.ts +++ b/src/sync-manager.ts @@ -332,8 +332,14 @@ export default class SyncManager { {}, ); await Promise.all( - Object.keys(this.metadataStore.data.files).map( - async (filePath: string) => { + Object.keys(this.metadataStore.data.files) + .filter((filePath: string) => { + // We should not try to sync deleted files, this can happen when + // the user renames or deletes files after enabling the plugin but + // before syncing for the first time + return !this.metadataStore.data.files[filePath].deleted; + }) + .map(async (filePath: string) => { const normalizedPath = normalizePath(filePath); const content = await this.vault.adapter.read(normalizedPath); newTreeFiles[filePath] = { @@ -342,8 +348,7 @@ export default class SyncManager { type: "blob", content: content, }; - }, - ), + }), ); await this.commitSync(newTreeFiles, treeSha); }