brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.74k stars 2.32k forks source link

Save As Fails With Long (But Valid) Filenames [macOS] #23688

Open Renara opened 2 years ago

Renara commented 2 years ago

Description

As the title says, when downloading a file with a long filename set via Save As, Brave Browser reports that the download failed, even if it's a valid filename for the target volume.

Steps to Reproduce

  1. Find an image to download, right-click and choose "Save image as…".
  2. Enter a long, but valid, filename. For example, 250 characters long (including the file extension).
  3. Save the file.

Actual result:

The download fails. It is possible to resume the "failed" download, in which case the file is saved but with the name truncated to 244 characters (including the extension).

Expected result:

The file should save successfully if the filename is valid for the target system and volume.

Reproduces how often:

Always on macOS.

Brave version (brave://version info)

1.40.107 Chromium: 103.0.5060.53 (Official Build) (x86_64)

Miscellaneous Information:

The limit appears to be 244 single byte characters, however the two main filesystems on modern macOS (HFS+ and APFS) both support 255, so there appears to be some discrepancy within Brave.

There are two obvious fixes that I can see:

hariomaurya commented 2 years ago

I am working on it. will share PR asap.

rebron commented 2 years ago

@Renara If you have Chrome installed, do you see this happening in Chrome as well?

hariomaurya commented 2 years ago

@rebron @Renara I have chrome and same issue persist in chrome as well. test on macos.

fmarier commented 2 years ago

I suspect the reason is that Chromium downloads an example.zip file to example.zip.crdownload first and then renames it when the download has finished. That way users can't open incomplete files by double-clicking on them.

The .crdownload suffix is 11 characters long, which would explain the 244 limit when the filesystem's own limit is 255 characters.

Renara commented 2 years ago

@Renara If you have Chrome installed, do you see this happening in Chrome as well?

Sorry for the slow reply (my e-mail notifications from GitHub are often weirdly slow to deliver, I really need to figure out why), I can confirm the issue also occurs in Chrome as well.

Does seem like the .crdownload suffix might be a plausible cause!