mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Use renameFile function instead to fix #63
This commit is contained in:
parent
358c498f99
commit
b337729c31
4 changed files with 10 additions and 10 deletions
|
|
@ -88,7 +88,7 @@ export function handleFileRename(file: TFile, oldPath: string, plugin: FolderNot
|
|||
excludedFolder.disableSync = true;
|
||||
updateExcludedFolder(plugin, excludedFolder, excludedFolder);
|
||||
}
|
||||
return plugin.app.vault.rename(file, oldPath).then(() => {
|
||||
return plugin.app.fileManager.renameFile(file, oldPath).then(() => {
|
||||
if (!excludedFolder) { return; }
|
||||
if (!excludedFolderExisted) {
|
||||
deleteExcludedFolder(plugin, excludedFolder);
|
||||
|
|
@ -147,8 +147,8 @@ async function renameFolderOnFileRename(file: TFile, oldPath: string, oldFolder:
|
|||
}
|
||||
}
|
||||
if (plugin.app.vault.getAbstractFileByPath(newFolderPath) || plugin.app.vault.getAbstractFileByPath(newFolderName || '')) {
|
||||
await plugin.app.vault.rename(file, oldPath);
|
||||
await plugin.app.fileManager.renameFile(file, oldPath);
|
||||
return new Notice('A folder with the same name already exists');
|
||||
}
|
||||
await plugin.app.vault.rename(oldFolder, newFolderPath);
|
||||
plugin.app.fileManager.renameFile(oldFolder, newFolderPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ tags: [excalidraw]
|
|||
file = await plugin.app.vault.create(path, content);
|
||||
} else {
|
||||
file = existingNote;
|
||||
plugin.app.vault.rename(existingNote, path);
|
||||
plugin.app.fileManager.renameFile(existingNote, path);
|
||||
}
|
||||
if (openFile) {
|
||||
await leaf.openFile(file);
|
||||
|
|
@ -112,7 +112,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
|
|||
updateExcludedFolder(plugin, excludedFolder, excludedFolder);
|
||||
}
|
||||
const newPath = `${folder.path}/${folder.name} (${file.stat.ctime.toString().slice(10) + Math.floor(Math.random() * 1000)}).${extension}`;
|
||||
plugin.app.vault.rename(folderNote, newPath).then(() => {
|
||||
plugin.app.fileManager.renameFile(folderNote, newPath).then(() => {
|
||||
if (!excludedFolder) { return; }
|
||||
if (!excludedFolderExisted) {
|
||||
deleteExcludedFolder(plugin, excludedFolder);
|
||||
|
|
@ -136,7 +136,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
|
|||
}
|
||||
}
|
||||
|
||||
await plugin.app.vault.rename(file, path);
|
||||
await plugin.app.fileManager.renameFile(file, path);
|
||||
plugin.addCSSClassToTitleEL(path, 'is-folder-note', true);
|
||||
plugin.addCSSClassToTitleEL(folder.path, 'has-folder-note');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default class FolderNameModal extends Modal {
|
|||
.onChange(async (value) => {
|
||||
if (value.trim() !== '') {
|
||||
if (!this.app.vault.getAbstractFileByPath(this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + value.trim())) {
|
||||
this.app.vault.rename(this.folder, this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + value.trim());
|
||||
this.plugin.app.fileManager.renameFile(this.folder, this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + value.trim());
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ export class SettingsTab extends PluginSettingTab {
|
|||
const folderNoteName = newTemplate.replace('{{folder_name}}', folder.name)
|
||||
const newPath = `${folder.path}/${folderNoteName}.${folderNote.extension}`;
|
||||
if (this.plugin.app.vault.getAbstractFileByPath(newPath)) { continue }
|
||||
this.app.vault.rename(folderNote, newPath);
|
||||
this.plugin.app.fileManager.renameFile(folderNote, newPath);
|
||||
}
|
||||
}
|
||||
this.plugin.settings.folderNoteName = newTemplate;
|
||||
|
|
@ -210,13 +210,13 @@ export class SettingsTab extends PluginSettingTab {
|
|||
} else {
|
||||
newPath = `${this.plugin.getFolderPathFromString(file.path)}/${folderNote.name}`;
|
||||
}
|
||||
this.app.vault.rename(folderNote, newPath);
|
||||
this.plugin.app.fileManager.renameFile(folderNote, newPath);
|
||||
} else if (this.plugin.settings.storageLocation === 'insideFolder') {
|
||||
if (this.plugin.getFolderPathFromString(folderNote.path) === file.path) {
|
||||
return;
|
||||
} else {
|
||||
const newPath = `${file.path}/${folderNote.name}`;
|
||||
this.app.vault.rename(folderNote, newPath);
|
||||
this.plugin.app.fileManager.renameFile(folderNote, newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue