Vault.rename(file, path) doesn't trigger link update

I’d like to report the same issue as reported by @sararkin at Vault.rename(file, path) is not updating existing links - Bug graveyard - Obsidian Forum.

Since the moderator suggest the bug should belongs to API sections. I’d like to report here again.
My system and obsidian version is different from sararkin, but the problem remains.

Steps to reproduce

const view = this.app.workspace.getActiveViewOfType(MarkdownView);
const newPath = "hoge.md";
this.app.vault.rename(view.file, newPath);

Expected result

Renames file and updates all links, same behavior as just renaming manually

Actual result

Renames the file, The vault.on(“rename”) event is indeed triggered. But existing links aren’t updated to point to the new file

Environment

  • Operating system: Windows 10
  • Obsidian version: v0.13.23

Thanks,
anselmwang

1 Like

This is the API you should use for rename and update links:

Thanks a lot, I have verified the API with this.app.fileManager.renameFile(this.app.vault.getAbstractFileByPath("abc/abc.md"), "abc/abc2.md"), it works perfectly!

2 Likes