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

trying to save overly long URL as file results in "filename too long error" #635

Open
ghost opened this issue Feb 11, 2022 · 3 comments
Open

Comments

@ghost
Copy link

ghost commented Feb 11, 2022

Describe your matter in detail

trying to save overly long URL as file results in "filename too long error" with firefox unable to "re-download" that file in downloads window either

ex.: https://cdn4.telesco.pe/file/d1aXFQbScE4e02KRUEwy5j6nJkJd3-8yO1oZQ6B6wppIdosdKQ5SK5b0d0ln7rPEKhcbNcah8qs_1SLu8ASZ9nUpVVzCtFPRwfHVxC2xfl_Nk9u-Nzw6TRVZLIP0GrK4frlnE5RaNzOKbX6du186Wrlh5N7r-rI-A5OFDd51iQ3-T8pFH0UXO7AvvFestCixkJF-aAhGBkA5BF_q9wtJCTnYq-OExlkJOM79pCyyRj9rkq4fFB2Xt17rfc4AClgDSlowqkNU6TNhmbcrCziTD8Ua2HFaWdO8EDFG5dbEq8Wm8nvxrPX9kTeVQKqEg1lz5l_xTSRmhW2zpCd7HVJd9g.jpg — 347 chars incl the file extension
(via https://t.me/alphynarium/304, so it's a real use-case)

which is still a valid length of a filename within an URL, but not on the most filesystems.

not sure if it's global firefox's of ever OS level issue tbh, but until lower levels of abstraction fix that,
it should prob be addressed on the userspace level

for example special characters in URLs are already getting auto-replaced,
so overly-long filenames should be truncated to a reasonable 128 chars?
or replaced with some UUID, and have additional text file with origin filename as the contents

Your System

  • Operating system: Ubuntu
  • Firefox version: 97
  • Gesturefy version: 3.2.4
@Robbendebiene
Copy link
Owner

Hi, thanks for the detailed report.

I would like to solve this by catching the error and then re-trigger the download with a shortened file name. However currently I'm not able to properly catch the error, even though the documentation claims it's possible.
The reason why I don't want to just always shorten the filename is that I want to use as much Firefox default behaviour as possible. Currently I leave the naming of the file entirely to Firefox.
Another option would be to extract the potential filename from the URL, check if its length exceeds a certain amount and then shorten the file name.

What error message do you get in the browser console? Because I'm getting OperationError: Could not remove the file at ...SpDkktUUvQ.jpg.part and OperationError: Could not remove the file at ... SpDkktUUvQ.jpg Which feels like Firefox itself doesn't even catch the error properly.

@ghost
Copy link
Author

ghost commented Feb 13, 2022

i think firefox just tries to save and the system-level error of "cant save" is all it gets

@Robbendebiene
Copy link
Owner

To give an update about the current state of the issue:

While there seems to exist some simple solutions like: extracting the file name from the URL or pre-querying the file, both of them have some drawbacks for the entire file-downloading and -naming implementation. Option one won't be able to get file names provided by the Content-Disposition header. Option two either introduces redundant requests, or lacks download progress feedback in the UI (if the entire file is downloaded via JavaScript and then passed as a blob to the download API)

The proper solution would be using the onDeterminingFilename callback which sadly is not supported (yet?) by Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1245652

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

No branches or pull requests

1 participant