This commit is contained in:
Lost Paul 2024-02-03 12:17:45 +01:00
parent f6744f75f8
commit b2fe971c28

View file

@ -135,6 +135,7 @@ async function renameFolderOnFileRename(file: TFile, oldPath: string, oldFolder:
plugin.addCSSClassToTitleEL(file.path, 'is-folder-note');
return;
}
let newFolderPath = '';
if (plugin.settings.storageLocation === 'insideFolder') {
newFolderPath = oldFolder.parent?.path + '/' + newFolderName;
@ -146,9 +147,11 @@ async function renameFolderOnFileRename(file: TFile, oldPath: string, oldFolder:
newFolderPath = `${parentFolderPath}/${newFolderName}`;
}
}
if (plugin.app.vault.getAbstractFileByPath(newFolderPath) || plugin.app.vault.getAbstractFileByPath(newFolderName || '')) {
if (plugin.app.vault.getAbstractFileByPath(newFolderPath)) {
await plugin.app.fileManager.renameFile(file, oldPath);
return new Notice('A folder with the same name already exists');
}
plugin.app.fileManager.renameFile(oldFolder, newFolderPath);
}