SimonSimCity / Xamarin-CrossDownloadManager

A cross platform download manager for Xamarin
MIT License
149 stars 68 forks source link

Using PathNameForDownloadedFile: Android suffixes filename by '-1' if file already exists #69

Closed BtrJay closed 7 years ago

BtrJay commented 7 years ago

Hi @SimonSimCity ,

I've found an issue that when I set PathNameForDownloadedFile for Android before calling

             downloadManager.PathNameForDownloadedFile = downloadFile => filePath; 

i.e. /storage/emulated/0/Android/data/com.builttoroam.podcast/files/Download/a2da6a8b-2b67-44ba-8478-2661/Audio.mp3

            var file = downloadManager.CreateDownloadFile(url);
            file.PropertyChanged += OnFilePropertyChanged;
            downloadManager.Start(file);

            // After this line, Android will create Audio.mp3 (empty) and Audio-1.mp3 (actual content is 
            written here)

Have you ever seen this issue before?

I've got this file path from PCLStorage plugin and seems working with iOS && UWP fine.

Just Android is where this issue has been come from.

Kind Regards,

Jay

SimonSimCity commented 7 years ago

Hi, @BtrJay

I just had this when starting the download twice - and that was expected. Can you please create a fork of this repository and change the example, so you get it there as well? I'll then have a closer look at it and find a way to fix it.

BtrJay commented 7 years ago

@SimonSimCity,

Sure, I will create a pull request for that shortly.

Kind Regards,

Jay Sim

BtrJay commented 7 years ago

Hi @SimonSimCity ,

I've created the pull request that creates the test for Android where you can replicate the issue I have.

Please have a look.

Kind Regards,

Jay Sim

BtrJay commented 7 years ago

My latest PR should include the fixes for this issue.

Please have a look and let me know if you have any issues/concerns.

Regards,

Jay

SimonSimCity commented 7 years ago

Thanks very much, I've fixed it, closed the PR and uploaded a new version (v1.3.2)