首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tauri window.__TAURI__.fs.readDir(.)无法读取目录错误:配置范围上不允许的路径。

Tauri window.__TAURI__.fs.readDir(.)无法读取目录错误:配置范围上不允许的路径。
EN

Stack Overflow用户
提问于 2022-03-29 13:36:44
回答 2查看 1.8K关注 0票数 0

我对Tauri很陌生,我正在尝试读取/ ls一个目录。

代码语言:javascript
复制
window.__TAURI__.fs.readDir("com.tauri.dev/", { dir: window.__TAURI__.fs.Dir.Data }).then(...

Unhandled Promise Rejection: path not allowed on the configured scope: /home/user/.local/share/com.tauri.dev/

好像是我搞砸了瞄准镜?我启用了所有我能想到的“允许列表”项,并且范围似乎被正确地定义了:

代码语言:javascript
复制
"allowlist": {
  "path": { "all": true },
  "all": true,
  "fs": {
    "all": true,
    "readFile": true,
    "writeFile": true,
    "readDir": true,
    "copyFile": true,
    "createDir": true,
    "removeDir": true,
    "removeFile": true,
    "renameFile": true,
    "scope": ["$DATA/com.tauri.dev/*"]
  }

怎么回事?

Tauri信息:

代码语言:javascript
复制
$ npm run tauri info

> tauri-app@0.0.0 tauri
> tauri "info"


Environment
  › OS: Pop!_OS 21.10 X64
  › Node.js: 17.7.0
  › npm: 8.5.2
  › pnpm: Not installed!
  › yarn: 1.22.17
  › rustup: 1.24.3
  › rustc: 1.59.0
  › cargo: 1.59.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.7(outdated, latest: 1.0.0-rc.8)
  › @tauri-apps/api [NPM]: 1.0.0-rc.3(outdated, latest: 1.0.0-rc.3)
  › tauri [RUST]: 1.0.0-rc.6,
  › tauri-build [RUST]: 1.0.0-rc.5,
  › tao [RUST]: 0.7.0,
  › wry [RUST]: 0.14.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:3000/
  › framework: Svelte

App directory structure
  ├─ .vscode
  ├─ js
  ├─ node_modules
  ├─ public
  ├─ css
  ├─ src
  ├─ img
  ├─ src-tauri
  ├─ old_nm
  ├─ doc
  └─ data
EN

回答 2

Stack Overflow用户

发布于 2022-05-14 16:55:32

它似乎需要基本路径和附加*的路径,才能在所引用的目录中工作。

代码语言:javascript
复制
"scope": ["$APP/*","$APP"]
票数 1
EN

Stack Overflow用户

发布于 2022-04-23 17:59:49

我在http中的tauri版本1.0.0-rc.3中也有类似的问题。

在tauri上看到了一些修复,并升级到一个未发布的git支持版本(在Cargo.toml中):

代码语言:javascript
复制
tauri = { git = "https://github.com/tauri-apps/tauri/", rev="834ccc51539401d36a7dfa1c0982623c9c446a4c", features = ["fs-read-file", "fs-write-file", "http-all",...

修复了HTTP问题,fs也为我工作(在tauri.conf.json中)

代码语言:javascript
复制
"allowlist": {
            "fs": {
                "readFile": true,
                "writeFile": true,
                "scope": ["$DATA/XXX/**"]
            },
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71663083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档