can't read directories recursively using fs/dialog plugin Tauri V2 #14516
-
|
After reading many posts about file system permissions, etc., I still don't understand how to properly grant read/write permissions to files/directories. Moreover, I need to get the directory tree recursively, since I'm creating a directory tree for my application. Every time I encounter hidden directories such as ".git" or ".vcode," I get the following error:
Moreover, when the hidden directory is on the first level, then in principle everything works, but it does not work with internal nesting. Example: private setSelectedFolderTree = async (
path: string
): Promise<FileTree[]> => {
const entries = await readDir(path)
const tree: FileTree[] = []
for (const entry of entries) {
const fullPath = `${path}/${entry.name}`
const node: FileTree = {
id: uuidv4(),
name: entry.name,
path: fullPath,
isDirectory: entry.isDirectory
}
if (entry.isDirectory) {
node.children = await this.setSelectedFolderTree(fullPath)
}
tree.push(node)
}
return tree
}
public setSelectedFolder = async () => {
try {
const path = await open({
multiple: false,
directory: true
})
console.log(path, "path")
if (path) {
const tree = await this.setSelectedFolderTree(path)
runInAction(() => {
this.FsStoreData.selectedPath = path
this.FsStoreData.selectedFileTree = tree
console.log(tree)
})
}
} catch (error) {
console.error(error)
}
}i'm calling setSelectedFolder function which receives the path from the dialog and then runs a recursive function to build the tree of this directory and it seems to me that the dialog permission that is given when opening does not extend to the following layers of directories. permissions: "permissions": [
"core:default",
"opener:default",
"dialog:allow-open",
"fs:allow-read-dir",
{
"identifier": "fs:scope",
"allow": [
{
"path": "**/*"
}
]
},
{
"identifier": "fs:allow-read-dir",
"allow": [
{
"path": "**/*"
}
]
}
]I tried using different permissions, specifying base directories and also using "*/**" but it still not working. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
For the file system plugin itself you can do what's shown all the way at the bottom in the before you try that though, can you check if enabling |
Beta Was this translation helpful? Give feedback.
For the file system plugin itself you can do what's shown all the way at the bottom in the
tipsection here https://v2.tauri.app/plugin/file-system/#scopesbefore you try that though, can you check if enabling
recursive: trueon the dialog.open call helps as well? Wondering how the dialog handles the hidden dirs