Remove temp file created by network.download()

Hi,

I have an app that downloads an image from a server every few minutes and displays it in the background. I use network.download(), ‘appname_bg.jpg’ as the filename and system.TemporaryDirectory for basedir.

Problem is, only the first image gets downloaded. On the next download I get “Failed to rename temp download file to final download file” error. I tried to remove it manually using os.remove() but it seems the file remained opened by some process because I get a “Permission denied” error on that line.

I spent a lot of time solving it but now I am stuck. Any ideas?

Regards,

Peter

You can’t do that.  Once you’ve displayed an image from the persistent storage on your device it is effectively locked.

If you want to get new images and display them, you’ll have to give them unique names every time you download them.

Put the images in the temporary folder so they get cleaned up as

A. The os decides it needs to clean up AND

B. As soon as they unlock or the app is exited.

roaminggamer: thanks for the help! So that’s why I can’t overwrite resource files while running the simulator…

As I have hundreds of backgrounds, I’ll have to alter my app to limit the number of downloads per launch (plus check the availabity of said background in temp folder as it might have been cleared up). Sounds sensible, anyway…

You can’t do that.  Once you’ve displayed an image from the persistent storage on your device it is effectively locked.

If you want to get new images and display them, you’ll have to give them unique names every time you download them.

Put the images in the temporary folder so they get cleaned up as

A. The os decides it needs to clean up AND

B. As soon as they unlock or the app is exited.

roaminggamer: thanks for the help! So that’s why I can’t overwrite resource files while running the simulator…

As I have hundreds of backgrounds, I’ll have to alter my app to limit the number of downloads per launch (plus check the availabity of said background in temp folder as it might have been cleared up). Sounds sensible, anyway…