Re: How much time do I have to move a NSURLSession temporary file?
Re: How much time do I have to move a NSURLSession temporary file?
- Subject: Re: How much time do I have to move a NSURLSession temporary file?
- From: Daryle Walker <email@hidden>
- Date: Wed, 01 Apr 2015 14:25:45 -0400
> On Apr 1, 2015, at 5:36 AM, Quinn The Eskimo! <email@hidden> wrote:
>
> On 31 Mar 2015, at 21:00, Daryle Walker <email@hidden> wrote:
>
>> Everything has been working for the past few trials, then spontaneously stopped working. Now I’m getting '“TempFile.whatever” doesn’t exist’ errors.
>
> Two things:
>
> o Make sure you're delegate queue is a serial queue (set maxConcurrentOperationCount to 1). Without that it's very easy to tie yourself up in knots here.
>
> o Are you sure that the file was created in the first place? I've seen situations where the download failed but -URLSession:downloadTask:didFinishDownloadingToURL: was called anyway and the file didn't exist. I haven't yet got to the bottom of the problem but I suspect it's related to a race condition described in the DevForums post referenced below.
>
> <https://devforums.apple.com/message/1115836#1115836>
I use the main thread ([NSOperationQueue mainQueue]) as the delegate queue. (I don’t have a delegate class, leaving that job to NSURLSession’s automatic delegate.)
The problem only started when I added the code to not move the temporary file when it is already on the same volume as the destination directory. (The problem happens about half of the time.) And it went away when I “#if 0” that code (so the file is unconditionally moved). That’s why my reasonable guess was that running this function blows some sort of timer the task handler has on keeping the file.
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden