NewPipe icon indicating copy to clipboard operation
NewPipe copied to clipboard

Pausing download/ejecting app while in progress makes download unrecoverable

Open ballo opened this issue 1 year ago • 8 comments

Checklist

  • [X] I am able to reproduce the bug with the latest version given here: CLICK THIS LINK.
  • [X] I made sure that there are no existing issues - open or closed - which I could contribute my information to.
  • [X] I have read the FAQ and my problem isn't listed.
  • [X] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • [X] This issue contains only one bug.
  • [X] I have read and understood the contribution guidelines.

Affected version

27

Steps to reproduce the bug

  1. Initiate download
  2. Pause download/let it continue.
  3. Use heavy apps to eject Newpipe from RAM/close Newpipe in any other way.
  4. Open Downloads.

Expected behavior

NewPipe will delete the paused download if it gets swapped out of ram. The file remains, but NewPipe can only overwite it rather than resume. This doesn't appear to be a problem if the download is interrupted. In this case. It will change the status of the download in the notifications and will always allow the download to be resumed. The issue is if you pause the download.

Current work-arounds:

  1. Disconnect data to cause the download interrupted error which works unlike pausing the download
  2. Use something else like yt-dlp (my current solution)

Actual behavior

No response

Screenshots/Screen recordings

No response

Logs

No response

Affected Android/Custom ROM version

No response

Affected device model

No response

Additional information

No response

ballo avatar May 15 '24 18:05 ballo

To be clear, the app handles ejection from RAM properly for an interrupted download, but not a paused one?

opusforlife2 avatar May 16 '24 01:05 opusforlife2

To be clear, the app handles ejection from RAM properly for an interrupted download, but not a paused one?

That's the behavior I witnessed, yes

ballo avatar May 17 '24 00:05 ballo

Nihil novi... Old problem https://github.com/TeamNewPipe/NewPipe/issues/7059

NewNewPipe avatar May 18 '24 10:05 NewNewPipe

I found the bug on DownloadManager.loadPendingMissions:

if (mis == null || mis.isFinished() || mis.hasInvalidStorage()) {
                //noinspection ResultOfMethodCallIgnored
                sub.delete();
                continue;
            }
   mis.threads = new Thread[0];

  boolean exists;
            try {
                mis.storage = StoredFileHelper.deserialize(mis.storage, ctx);
                exists = !mis.storage.isInvalid() && mis.storage.existsAsFile();
            } catch (Exception ex) {
                Log.e(TAG, "Failed to load the file source of " + mis.storage.toString(), ex);
                mis.storage.invalidate();
                exists = false;
            }

In this commit mis.hasInvalidStorage() is called before mis.storage being deserialized (resulting in always failing in checking if "mis.storage.existsAsFile" ) and hence executing sub.delete(); (deleting the pending downloads)

https://github.com/TeamNewPipe/NewPipe/pull/6778/commits/1822d216763b92b563179e2a68c0c2bbb2020870

The solution is just remove that redundant check that was done after anyway:

if (mis == null || mis.isFinished() ) {
                //noinspection ResultOfMethodCallIgnored
                sub.delete();
                continue;
            }
...

It's quite a nasty bug because many people use mainly the download function and till version 0.21.8 was working properly (2021).

liloman avatar Feb 09 '25 23:02 liloman

@liloman sorry for the late response, and thank you for investigating! Could you open a pull request? Otherwise let me know, I can open one myself. :-)

By the way, we are receiving many reports of this bug in the email, too.

Stypox avatar May 12 '25 09:05 Stypox

I get this bug every day. How annoying. I hope they fix it in the next update. Cheers.

Alvenereo avatar May 15 '25 00:05 Alvenereo