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

Resource hash in filename if copy/open/downloading file in root dir #210

Open
jeflem opened this issue Aug 15, 2024 · 1 comment
Open

Resource hash in filename if copy/open/downloading file in root dir #210

jeflem opened this issue Aug 15, 2024 · 1 comment

Comments

@jeflem
Copy link
Contributor

jeflem commented Aug 15, 2024

If a jupyter-fs file browser (for a local file system, osfs://) is used for copying, opening or downloading a file which is not in a subfolder, then the filename will contain the resource hash:

  • copy: destination file name will be hash:filename (jupyter-fs will show two files with identical names, but terminal knows the truth)
  • open: tab title in JupyterLab will be hash:filename
  • download: webbrowser's suggested filename for saving will be hash_filename (Firefox)

For files in subdirectories everything works as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Configure osfs:// resource for jupyter-fs.
  2. Navigate to the highest level (root).
  3. In the file browser double click a file.
  4. Look at the editor's tab title.

or
3. right-click a file, then copy, then paste

or
3. right-click a file, then download

Expected behavior
Resource hash shouldn't appear in the GUI. Especially for copying, destination filename should be filename-Copy-1 or the like.

Desktop (please complete the following information):
tested on Debian 12 with Firefox 115.14 and

  • JupyterLab 4.0.11
  • jupyter-fs main branch

Additional context
For copying jupyter-fs calls Jupyter Server's AsyncContentsManager.copy. There the source path is tested for containing /. If there's no / then the whole path (including resource hash) is considered as filename, causing the troubles.

A (hacky) workaround is to modify jupyter-fs' _resolve_path in pathutils.py to prepend ./ to every path not containing /. Then every path contains / and splitting at the last / to get the filename yields a valid directory path (including the resource hash) and the correct filename. This seems to solve the problem for copy and download, but not for open.

@jeflem
Copy link
Contributor Author

jeflem commented Aug 15, 2024

Same problem with webdav:// resources. And also with current JupyterLab 4.2.4

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

No branches or pull requests

1 participant