delete history for deleted files
Similar to the "rename" case, I added an event handler to clean up the `vault-stats.json` when a file is deleted. Moreover, I added a sanity check on the "rename" event handler.
This commit is contained in:
parent
6676fc69f4
commit
da44785003
1 changed files with 11 additions and 3 deletions
|
@ -25,9 +25,17 @@ export default class StatsManager {
|
|||
);
|
||||
|
||||
this.vault.on("rename", (new_name, old_path) => {
|
||||
const content = this.vaultStats.modifiedFiles[old_path];
|
||||
delete this.vaultStats.modifiedFiles[old_path];
|
||||
this.vaultStats.modifiedFiles[new_name.path] = content;
|
||||
if (this.vaultStats.modifiedFiles.hasOwnProperty(old_path)) {
|
||||
const content = this.vaultStats.modifiedFiles[old_path];
|
||||
delete this.vaultStats.modifiedFiles[old_path];
|
||||
this.vaultStats.modifiedFiles[new_name.path] = content;
|
||||
}
|
||||
});
|
||||
|
||||
this.vault.on("delete", (deleted_file) => {
|
||||
if (this.vaultStats.modifiedFiles.hasOwnProperty(deleted_file.path)) {
|
||||
delete this.vaultStats.modifiedFiles[deleted_file.path];
|
||||
}
|
||||
});
|
||||
|
||||
this.vault.adapter.exists(STATS_FILE).then(async (exists) => {
|
||||
|
|
Loading…
Reference in a new issue