Pausing download/ejecting app while in progress makes download unrecoverable
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
- Initiate download
- Pause download/let it continue.
- Use heavy apps to eject Newpipe from RAM/close Newpipe in any other way.
- 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:
- Disconnect data to cause the download interrupted error which works unlike pausing the download
- 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
To be clear, the app handles ejection from RAM properly for an interrupted download, but not a paused one?
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
Nihil novi... Old problem https://github.com/TeamNewPipe/NewPipe/issues/7059
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 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.
I get this bug every day. How annoying. I hope they fix it in the next update. Cheers.