BackgroundDownload icon indicating copy to clipboard operation
BackgroundDownload copied to clipboard

Android - Downloaded File is deleted when DownloadStatus becomes Done

Open lorenzocalosi opened this issue 5 years ago • 6 comments

I've tested this on different devices, and it only happens when i seem to use a device running Android 7.0. When the download changes status to Done, then the file is deleted. Before that, i can see that the file is present in the correct destination folder, but as soon as it finishes downloading, the file is gone.

lorenzocalosi avatar Aug 27 '19 12:08 lorenzocalosi

How do you monitor the files presence? You haven't cleared the files in Download Manager app?

aurimasc avatar Sep 05 '19 12:09 aurimasc

Me too, the file is deleted when the download is complete. If I don't use 'using', and don't explicitly call BackgroundDownload.Dispose (), it won't be deleted. The file seems to be deleted during the BackgroundDownload.Dispose () process.

Of course, if I omit Dispose (), the completed download will not be deleted from BackgroundDownload.backgroundDownloads. This is not what I want

Unity 2020.1.0 / Android 8.0

cseheon avatar Jan 16 '20 07:01 cseheon

Gotch, thanks for info. This should fix it: https://github.com/Unity-Technologies/BackgroundDownload/pull/13

aurimasc avatar Jan 20 '20 15:01 aurimasc

The Issue ist still here. The workaround with renaming the file works quite well though, just append ".part" to the file path and before reaching the using block use File.Move to rename the file back without the ".part" in the end.

rubit0 avatar Feb 02 '20 23:02 rubit0

@rubit0 Could you clarify what you mean by the "issue is still there"? I'm not able to reproduce the issue anymore with the fix that @aurimasc mentioned :) If you are still reproducing, could you attach an example of your code? Just want to make sure that it doesn't differ with my implementation.

Thank you

MantsSk avatar Feb 12 '20 11:02 MantsSk

@sidass I mean that it is not fixed on Unity side and yes the workaround via renaming the file works fine so far.

rubit0 avatar Feb 13 '20 22:02 rubit0