fix(ResourcePathResolver): Use vault-relative paths for adapter.list()

- Changed adapter.list() to use empty string for vault root instead of absolute path
- Convert vault-relative paths to absolute paths when returning for external tools
- Fixes cross-platform compatibility issues per CodeRabbit review
- Maintains existing functionality while following Obsidian API best practices

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jarvis committed 2025-09-25 13:45:57 +02:00
1 parent 3782f0a7fb
commit b47571dccd
2 files changed
+237 -2

No files matched your search

@@ -97,7 +97,8 @@ export class ResourcePathResolver {
return foundResourcePaths;
}
const vaultContents = await this.plugin.app.vault.adapter.list(vaultBasePath);
// Use vault root (empty string) for adapter.list() to get vault-relative paths
const vaultContents = await this.plugin.app.vault.adapter.list('');
for (const item of vaultContents.folders) {
const itemName = item.split('/').pop() || item;
@@ -109,7 +110,9 @@ export class ResourcePathResolver {
/\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i.test(file)
);
if (hasImages) {
foundResourcePaths.push(item);
// Convert vault-relative path to absolute path for external tools
const absolutePath = pathUtils.joinPath(vaultBasePath, item);
foundResourcePaths.push(absolutePath);
}
} catch {
// Ignore directories we can't read