Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the file selection using external command with a new "download" mode #8140

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Twix53791
Copy link

I am coming back on this idea... I will see if I can get rid of the previous errors in the tests...

@Twix53791
Copy link
Author

Twix53791 commented Mar 23, 2024

It seeems quite OK for me. I try to made minimal changes. The logic of _validated_selected_files is absolutly not changed as you warned me in my last pull request @The-Compiler, actually, the 'download' mode I added bypass all the checks of _validated_selected_files, excepting the one forbiding multiple files selection. I think it is OK because qutebrowser seems to manage any possible situation : in case of the selected file doesn't exist, it can create it, even create new directories ; if it is a directory, the file is downloaded into ; and if threats to overwrite a special file, qutebrowser has a warning to that case.

This behavior allows people to rename the file downloaded. If a folder is given, the file is downloaded into keeping its original name, and if a filename is given, as a basename or a full path, it is downloaded under this name, or in the default folder qutebrowser set, or in the path given.

About the 5 tests which didn't succed, I can't understand how they could be linked to my changes. When I read the logs, I saw a problem about a ' test_clicking_on_focused_element_when_there_is_none', another one a ssl client socket error, a problem in 'test_insert_mode.py'... It seems completely unrelated.

@The-Compiler
Copy link
Member

For context, #7884 was the original PR. Unfortunately. it looks like you force-pushed and removed your changes there, so I'm lacking a bit of context.

What's the problem you're trying to solve here exactly? It looks like right now you're adding a new prompt mode but it's not actually used anywhere at all, which means I can't see how this would change any behavior.

I agree the test failures look unrelated. Sadly we're struggling quite a bit with flaky tests. If it looks unrelated and only happens in one environment (rather than all of them), chances are big it's just flaky unfortunately.

@The-Compiler The-Compiler added this to Inbox in Pull request backlog via automation Mar 24, 2024
@The-Compiler The-Compiler moved this from Inbox to WIP in Pull request backlog Mar 24, 2024
@mschilli87
Copy link
Contributor

mschilli87 commented Mar 25, 2024

@The-Compiler:

Unfortunately. it looks like you force-pushed and removed your changes there, so I'm lacking a bit of context.

In case it helps, you can still see the original commit before the force-push.


edit: Here is the full diff between #7884's pre-force push state and the last commit on this PR for your convenience.

@Twix53791
Copy link
Author

Twix53791 commented Mar 25, 2024

For context, #7884 was the original PR. Unfortunately. it looks like you force-pushed and removed your changes there, so I'm lacking a bit of context.

What's the problem you're trying to solve here exactly? It looks like right now you're adding a new prompt mode but it's not actually used anywhere at all, which means I can't see how this would change any behavior.

I agree the test failures look unrelated. Sadly we're struggling quite a bit with flaky tests. If it looks unrelated and only happens in one environment (rather than all of them), chances are big it's just flaky unfortunately.

Hi @The-Compiler, yes, sorry, I messed up with git trying to reset the branch to the main state... I am not making enough often contribs to projects to get used to git!

My setup (the context)

I am using a script launching ranger as file external selector. In config.py c.fileselect.handler = 'external', and then in the prompt to use it. Until now amazing. But the problem is when you download a file now in qutebrowser, the external file selector is launch in the "folder" mode, to select a folder where to download the file. It doesn't allow to select a file to overwrite it or a non existent file to rename the downloaded file, a feature very important to me. Using the 'single-file' mode instead is not more satisfying as again it is not possible to select a "non-existent" file (= rename the file to download), and it doesn't allow to select a folder to just download the file into.

The solution proposed by this pull request

SO, that's why I created this new mode, 'download', using it in the config c.fileselect.download.command = ['ranger-filepicker', '{}', 'download']. This mode allows basically anything: select a folder to download the file into, select a file to overwrite it, send a new non existing path to rename the file to download, even create a new folder in the path. It allows a lot of possibilities, and it is in the external command script to limit those, according to individual preferences.
I think this "freedom" is not a problem because qutebrowser handles it, in case of permissions issues, non valid path format, creating directories y/n, overwriting files y/n, overwriting 'special files' warning, etc.

Its changes are minimal it just:

  • add a new config option in configdata.yml to use c.fileselect.download.command
  • allows to use this mode in shared.py FileSelectionMode and choose_file functions
  • make this mode bypass all the checks of the _validated_selected_files function in shared.py, except the one forbiding mutiple paths selection.

PS: here are the files of the previous #7884 pull request before the force push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants