tauri: Unhandled Promise Rejection: cannot traverse directory

Describe the bug

image image

dialog.open() is going well, The path was obtained successfully.

then use fs.readDir() to read the path, got cannot traverse directory

Reproduction

No response

Expected behavior

No response

Platform and versions

yarn tauri info
yarn run v1.22.17
warning package.json: No license field
$ tauri info

Operating System - Mac OS, version 12.2.1 X64

Node.js environment
  Node.js - 14.19.0
  @tauri-apps/cli - 1.0.0-rc.4
  @tauri-apps/api - 1.0.0-rc.1

Global packages
  npm - 6.14.16
  pnpm - Not installed
  yarn - 1.22.17

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-x86_64-apple-darwin

App directory structure
/dist
/node_modules
/public
/src-tauri
/.vscode
/src

App
  tauri - 1.0.0-rc.2
  tauri-build - 1.0.0-rc.2
  tao - 0.6.2
  wry - 0.13.2
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:3000/
  framework - Vue.js
✨  Done in 37.36s.



### Stack trace

_No response_

### Additional context

_No response_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 23 (10 by maintainers)

Most upvoted comments

However, if my application does need to access any file directory, can it only be satisfied by customizing Rust

Yes.

In regards to your initial question however, we’re looking into some kind of whitelist system to allow user-selected paths (dialog/file-drop) to bypass this limitation.

Tauri is a framework for building tiny, blazing-fast binaries for all major desktop platforms.

The whitelisting system sounds great, if the user can’t use their directory/file selected in the dialog in the desktop application, they will get confused about it. With the best wishes awaiting the whitelisting system.

That would require them to edit the paths returned from the dialog to not contain the /home/username/ path and use the BaseDirectory enum on the readDir api. Let’s just say that we really didn’t think that one through 😅 but that’s what pre-release versions are for and luckily we have enough users trying out these versions and report stuff we missed💪