Feodor2 / Mypal68

web browser
Other
608 stars 37 forks source link

Fix downloading executable files in some scenarios #396

Open K4sum1 opened 6 months ago

K4sum1 commented 6 months ago

Sometimes I have an issue mostly with executable files where the download will fail because Firefox can't remove the blank 0kb file that it makes to allocate the file name. Starting in 92, this was mitigated by just tacking (1) to the end if this happens.

There are two ideas I have on how to fix it.

1: Not allocate the file name (preferred)

This means when making the download, just not creating the 0kb file with the file name and extension of the file being downloaded. Firefox does not need this because it can make the (1) files just fine. This is also the way Chrome does downloads.

2: Apply the fix from 92a1 (20210730215633)

I believe this is an unintentional side effect of this commit below, because I can't seem to find anything else that could fix the issue.

https://hg.mozilla.org/mozilla-central/rev/0f01ac89ab32

In case I got this wrong, it's one of these commits that happened between the last build to fail, and the first to append (1).

https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=1f2953ad605e&tochange=02e2fec3cd21862d45230367a18fc366e47238c6

NS-Clone commented 6 months ago

оффтоп но немного близко спермиум если в папке загрузок есть файл с таким же именем прям уже в окне сохранения меняет имя на ххххх(1) что очень удобно в фаирфоксах же приходитсо постоянно подтверждать что ты заменять никого не хочешь и вводить абракадабру которая опять часто повторяетсо с существующим файлом....

K4sum1 commented 6 months ago

Huh it's not unintentional. I took a look and it definitely is just part of the commit but a unlisted change.


        .catch(err => {
          if (err.becauseTargetFailed) {
            // In case we cannot write to the target file
            // retry with a new unique name
            let uniquePath = DownloadPaths.createNiceUniqueFile(
              new FileUtils.File(this.target.path)
            ).path;
            this.target.path = uniquePath;
            return this.start();
          }
          return Promise.reject(err);
        })
        .catch(err => {
          this.error = err;
          this._notifyChange();
        });```
Feodor2 commented 6 months ago

I just have checked, its already do (1) tacking. Create blank file, restrict access, save a file upon it.

K4sum1 commented 6 months ago

It doesn't do it for me, I can get the download to pretty consistently fail.