Use case or problem
I have multiple vaults, one for each of my projects. I categorize vaults by placing them in folders, like this example file hierarchy:
- Apps/
- Project A/
- .obsidian/
- Project B/
- .obsidian/
- etc/
- .obsidian/
- Repositories/
- Project F/
- .obsidian/
- etc/
- .obsidian/
- Miscellaneous/
- etc/
- .obsidian/
I use iCloud to sync my vaults between mobile and desktop, which is all well and good until I try to access a vault from the mobile app. Only the top level folders that I use for organization are displayed. When I tap one, wanting to access the directory’s (the vaults), Obsidian loads the directory itself as a vault, and creates .obsidian
in that “grouping” directory. It also loads the plugins and files from each of those vaults, causing the app to be unusable for a while (2+ minutes in my case) due to loading the workspace and indexing.
For example, the app will display Apps
, Repositories
, and Miscellaneous
from the above hierarchy. Tapping Apps
will then:
- Create
Apps/.obsidian/
- Open
Project A
,Project B
, andetc
as folders inside the newApps
vault instead of their own vaults.
Proposed solution
When creating a vault, Obsidian creates .obsidian
in the main vault directory. Therefore, if .obsidian
isn’t there, a directory should not be treated as a vault, and instead be displayed as a foldout menu. When displaying vaults to open, a search should begin at the sync directory root and continue recursively until a directory containing .obsidian
is found, at which point the directory is considered a vault and is displayed in the list.
Some pseudo-code as an implementation example:
func loadVaultsRecursive(from file) -> [URL] {
if (file.type != .folder) {
return []
}
if (file.contents.contains(".obsidian")) {
return [file]
} else {
return file.contents.flatMap(loadVaultsRecursive)
}
}
let validVaults = loadVaultsRecursive(from: syncDirectory)