add listerner for renamed file

This change avoid to create duplicate data in `vault-stats.json` when a
file is renamed by copying the data from the old path to the new one.
This commit is contained in:
Davide Aversa 2023-01-24 19:53:26 +01:00
parent 9e6550f407
commit 67c8162296

View file

@ -24,6 +24,12 @@ export default class StatsManager {
false
);
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;
});
this.vault.adapter.exists(STATS_FILE).then(async (exists) => {
if (!exists) {
const vaultSt: VaultStatistics = {