Skip to content

Clarify Vault API limitations working w/ hidden (dot) directories #186

@k-cabral

Description

@k-cabral

Context

Spent quite some time today trying to figure out why I couldn't access anything inside .obsidian using the Vault API (namely, getFileByPath()/getAbstractFileByPath()) until I asked on Discord and figured the way to go was using DataAdapter (vault.adapter).

Issue

I tested every function in the Vault API that takes a path as a parameter and tried manipulating test files/folders inside the .obsidian path. Functions that create or copy a file/folder do what they're meant to do, but return null instead of the relevant object.

Function name Status
rename 🟢 Works normally
create 🟡 Works partially
createBinary 🟡 Works partially
createFolder 🟡 Works partially
copy 🟡 Works partially
getFolderByPath 🔴 Doesn't work at all
getAbstractFileByPath 🔴 Doesn't work at all
getFileByPath 🔴 Doesn't work at all

Proposal

Document this behavior in the reference for the relevant functions and in the main Vault docs, suggesting the use of DataAdapter instead of the Vault API for hidden files.

Proposed wording

Based on how it's written in the DataAdapter documentation

Work directly with files and folders inside a vault. If possible prefer using the Vault API over this.

I suggest we append to each relevant page's description the following phrase:

Prefer using DataAdapter when working with hidden files and folders, such as those inside .obsidian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions