Clearing temp download files after Network Failure using NSURLSession

泪湿孤枕 提交于 2019-12-13 00:36:12

问题


I'm using NSURLSession to download a list of files in my app.I have support for background downloading and is working correctly.But some times when the WiFi connectivity is lost while the app is in background,some files remain in the temp directory(com.apple.nsnetworkd) and is not getting removed.So when i download a new set of files these files still remains in the directory.This situation repeats on WiFi failures and the set of files keeps accumulating.Any way to solve this issue? Will there be any problem if i try to remove these files manually?

If WiFi connection is active then everything works fine and tmp directory is cleared automatically.


回答1:


Trying resuming the task or don't worry if you still find it ios to handle it when required to free the space

From Doc A file URL where the temporary file can be found. Because the file is temporary, your delegate method must either open the file for reading or move it to a permanent location in your app’s sandbox container directory before returning.



来源:https://stackoverflow.com/questions/22857379/clearing-temp-download-files-after-network-failure-using-nsurlsession

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!