Contains utility functions for managing files in Obsidian.
| Function | Description |
|---|
| addAlias | Adds an alias to the front matter of a given file if it does not already exist. |
| deleteAlias | Deletes an alias from the front matter of a given file if it exists. |
| processFrontmatter | Processes the front matter of a given file, allowing modifications via a provided function. |
| waitForPendingLinkUpdates | Waits until Obsidian’s own in-flight link update has decided which links to rewrite. FileManager.runAsyncLinkUpdate() snapshots every reference’s resolved paths, sets FileManager.inProgressUpdates to an array, and invokes the passed handler — the handler being what performs the actual rename. In its finally block it sets inProgressUpdates back to null and then immediately calls FileManager.updateAllLinks(), whose per-reference decision — rewrite only when the link’s resolved paths changed — runs synchronously, with no await in between. So observing a null inProgressUpdates proves that decision has already been made. That matters for any code that temporarily registers a phantom file at a path that no longer exists (see registerFiles in metadata-cache.ts) and holds that registration across an await: while it is live, a link to the old path still resolves, so Obsidian concludes nothing changed and silently rewrites nothing. Awaiting this function before registering keeps the phantom out of that decision. |