TWRDownloadManager icon indicating copy to clipboard operation
TWRDownloadManager copied to clipboard

2 Progress Values

Open Hackmodford opened this issue 9 years ago • 8 comments

I'm not sure if this is a bug or not.

If I start a download, then kill my app (using the stop button in xCode), then resume my app and start the download again, the progress block seems to be fired twice with different values.

Any idea why it does that?

Hackmodford avatar Dec 14 '15 15:12 Hackmodford

I did some testing and discovered that I have multiple tasks piling up in the background session manager.

This post helped me find the issue. http://stackoverflow.com/questions/23492311/nsurlsession-background-task-avoid-duplicates

Hackmodford avatar Dec 14 '15 23:12 Hackmodford

Here's where I'm lost. If I start a download request, and the app is killed or suspended. Doesn't TWRDownloadManager lose track of the download objects in the download array?

How does it know where to copy the files when it's done downloading?

Hackmodford avatar Dec 15 '15 18:12 Hackmodford

I'm experiencing the same issue.

ahmedk92 avatar Sep 05 '16 13:09 ahmedk92

I am surprised to see that this is an issue. The whole reason why I chose this library was because of its ability to perform background tasks. If that doesn't work, then Houston we have a problem.

@Hackmodford, did you check in your code that a download was not in progress and that the file didn't exist before requesting the download?

asiby avatar Apr 24 '17 01:04 asiby

This only happens when you kill the app with Xcode or if the app somehow crashes, the reason behind this is that background tasks are not killed by Xcode when you stop execution, the background task stays running with the same identifier, thus when you open the app again the handler will fire twice due to the recent "lost" download, and the actual download you're starting.

samisharafeddine avatar Apr 24 '17 12:04 samisharafeddine

I see. I was under the impression that the whole purpose of URL session was precisely to be able to handle this kind of situation amongst others.

I will check if it's not due to the way it was implemented in TWRDownloadManager.

On Mon, Apr 24, 2017 at 8:57 AM, Sami Sharaf [email protected] wrote:

This only happens when you kill the app with Xcode or if the app somehow crashes, the reason behind this is that background tasks are not killed by Xcode when you stop execution, the background task stays running with the same identifier, thus when you open the app again the handler will fire twice due to the recent "lost" download, and the actual download you're starting.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chasseurmic/TWRDownloadManager/issues/24#issuecomment-296658442, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbz-lnCVYDATWI9448YMc3187MnUKWrks5rzJw6gaJpZM4G01pn .

asiby avatar Apr 24 '17 17:04 asiby

I'm 100% confident that this is caused by NSURLSessionDownloadTask itself since i already tried writing my own library using NSURLSession and ended up with the same exact results.

samisharafeddine avatar Apr 24 '17 18:04 samisharafeddine

Ok. I will ready about it and see what's being missed.

On Mon, Apr 24, 2017 at 2:51 PM, Sami Sharaf [email protected] wrote:

I'm 100% confident that this is caused by NSURLSessionDownloadTask itself since i already tried writing my own library using NSURLSession and ended up with the same exact results.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chasseurmic/TWRDownloadManager/issues/24#issuecomment-296788094, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbz-m0RAOKzzKqiNhwQA8kTzt2JY0s9ks5rzO8ggaJpZM4G01pn .

asiby avatar Apr 25 '17 01:04 asiby