mirror of
https://github.com/firstsun-dev/git-files-sync.git
synced 2026-07-22 17:20:30 +00:00
fix(sync): clear sync metadata on vault file delete
Files deleted outside the plugin's own delete UI (e.g. via Obsidian's file explorer) left their syncMetadata entry behind indefinitely. detectRename's rename-matching scan treats every such orphan as a rename candidate and does a live remote getFile lookup for it on every future single-file push, which surfaces as a flood of 404s against paths that were simply deleted, not renamed. Register a vault 'delete' listener that clears the metadata entry as soon as Obsidian reports the delete, so orphans stop accumulating.
This commit is contained in:
parent
1fc27ab1b6
commit
1a369b36ed
1 changed files with 13 additions and 0 deletions
13
src/main.ts
13
src/main.ts
|
|
@ -133,6 +133,19 @@ export default class GitLabFilesPush extends Plugin {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// A file deleted outside the plugin's own delete UI (e.g. from Obsidian's
|
||||||
|
// file explorer) would otherwise leave its syncMetadata entry behind
|
||||||
|
// forever; detectRename's rename-matching scan treats every such orphan
|
||||||
|
// as a rename candidate and does a live remote lookup for it on every
|
||||||
|
// future single-file push, so clear it as soon as Obsidian reports the delete.
|
||||||
|
this.registerEvent(
|
||||||
|
this.app.vault.on('delete', (file) => {
|
||||||
|
if (file instanceof TFile) {
|
||||||
|
void this.sync.clearMetadata(file.path);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
await this.checkForUpdateNotice();
|
await this.checkForUpdateNotice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue