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:
ClaudiaFang 2026-07-14 13:21:32 +00:00
parent 1fc27ab1b6
commit 1a369b36ed

View file

@ -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();
}