Repository navigation
fix(sftp): stop the folder picker hanging on a restricted folder - #356
Merged
Merged
Conversation
Owner
|
thanks @antoinekh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the Windows desktop app, downloading several files from the SFTP panel does nothing when the folder picked is Downloads itself. The folder dialog opens in Downloads, so this is the most natural choice. Every later download of several files, by button or by dragging, then fails with
Failed to execute 'showDirectoryPicker' on 'Window': File picker already active.until the app restarts.Cause
Chromium blocks some folders themselves for the File System Access API (home, Desktop, Documents, Downloads; their children are allowed) and also system folders such as AppData and Program Files. Chromium shows its own prompt when one is picked; Electron instead emits the session event
file-system-access-restrictedand waits for a listener to call back withallow,denyortryAgain. The app session has no listener, so the callback is never called, theshowDirectoryPicker()promise never settles, and Chromium keeps the picker marked as active.Fix
The app session (
session.defaultSession) now answersallowtofile-system-access-restricted: the folder is always one the user picked in the native dialog, and the download never replaces a file already there. Web-host windows use their own session partitions and are not affected.Testing
tests/unit/electron/file-system-access.test.ts: it emits the event for a Downloads path on a fake session and checks the callback getsallow.typecheckandpnpm lintpass.pnpm test: 2461 tests pass.unit/electron/web-windows.test.tsfails because the Electron binary is not installed on my machine (Electron failed to install correctly). Three server and Electron tests time out only under the full-suite load and pass alone. None of them use this change.