diff --git a/src/main.ts b/src/main.ts index a61d630..23de1df 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,7 +17,6 @@ import { ArrangeHandler } from "./arrange"; import { CreateHandler } from "./create"; import { isExcluded } from "./exclude"; import { getMetadata } from "./settings/metadata"; -import { path } from "./lib/path"; export default class AttachmentManagementPlugin extends Plugin { settings: AttachmentManagementPluginSettings; @@ -253,19 +252,14 @@ export default class AttachmentManagementPlugin extends Plugin { await this.saveSettings(); const oldMetadata = getMetadata(oldPath); - // if the user have used the ${date} in `Attachment path` this could be not working, since the date will be changed. - // fixed by travese from parent folder + // if the user have used the ${date} in `Attachment path` this could be not working, since the date will be change. const oldAttachPath = oldMetadata.getAttachmentPath(setting, this.settings.dateFormat); - this.app.vault.adapter.exists(path.dirname(oldAttachPath)).then((exists) => { + this.app.vault.adapter.exists(oldAttachPath).then((exists) => { if (exists) { - this.app.vault.adapter.list(path.dirname(oldAttachPath)).then((data) => { - data.folders.forEach((folder) => { - checkEmptyFolder(this.app.vault.adapter, folder).then((empty) => { - if (empty) { - this.app.vault.adapter.rmdir(folder, true); - } - }); - }); + checkEmptyFolder(this.app.vault.adapter, oldAttachPath).then((empty) => { + if (empty) { + this.app.vault.adapter.rmdir(oldAttachPath, true); + } }); } }); @@ -294,16 +288,12 @@ export default class AttachmentManagementPlugin extends Plugin { const oldMetadata = getMetadata(file.path); const { setting } = getOverrideSetting(this.settings, file); const oldAttachPath = oldMetadata.getAttachmentPath(setting, this.settings.dateFormat); - this.app.vault.adapter.exists(path.dirname(oldAttachPath), true).then((exists) => { + this.app.vault.adapter.exists(oldAttachPath, true).then((exists) => { if (exists) { - this.app.vault.adapter.list(path.dirname(oldAttachPath)).then((data) => { - data.folders.forEach((folder) => { - checkEmptyFolder(this.app.vault.adapter, folder).then((empty) => { - if (empty) { - this.app.vault.adapter.rmdir(folder, true); - } - }); - }); + checkEmptyFolder(this.app.vault.adapter, oldAttachPath).then((empty) => { + if (empty) { + this.app.vault.adapter.rmdir(oldAttachPath, true); + } }); } });