fluttercommunity / fluttercommunity/flutter_downloader

Unable to re-download same file even when file is deleted.

Open
#509 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Kotlin
Stars
940
Forks
561
Avg merge
1h 18m
Merged PRs (30d)
1

Description

As title states. I'm running targetSDK 30 on Android 11 will all permissions granted. When trying to download a single new file everything works correctly. But when i try to re-download same file to the same place after it was deleted i'm getting following error:

```
D/DownloadWorker(14725): Update notification: {notificationId: 2, title: Test-Title.zip, status: 4, progress: -1}
W/System.err(14725): java.io.FileNotFoundException: /storage/emulated/0/Download/Test/Test-Title.zip: open failed: EEXIST (File exists)
W/System.err(14725): at libcore.io.IoBridge.open(IoBridge.java:492)
W/System.err(14725): at java.io.FileOutputStream.(FileOutputStream.java:236)
W/System.err(14725): at java.io.FileOutputStream.(FileOutputStream.java:157)
W/System.err(14725): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.java:346)
W/System.err(14725): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.java:203)
W/System.err(14725): at androidx.work.Worker$1.run(Worker.java:85)
W/System.err(14725): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(14725): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(14725): at java.lang.Thread.run(Thread.java:923)
W/System.err(14725): Caused by: android.system.ErrnoException: open failed: EEXIST (File exists)
W/System.err(14725): at libcore.io.Linux.open(Native Method)
W/System.err(14725): at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
W/System.err(14725): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
W/System.err(14725): at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
W/System.err(14725): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8367)
W/System.err(14725): at libcore.io.IoBridge.open(IoBridge.java:478)
W/System.err(14725): ... 8 more
I/WM-WorkerWrapper(14725): Worker result SUCCESS for Work [ id=b50c1cf0-71a9-465c-bd34-b0800d883208, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
```

[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.1110], locale pl-PL)
compileSdkVersion 30
targetSdkVersion 30
Android 11

When i downgraded compileSdkVersion to 29 it works properly. Any ideas? Is this related to the scoped storage?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure on Android 11 with targetSdkVersion 30, then inspect DownloadWorker.java at downloadFile line 346 and doWork line 203. Compare behavior with compileSdkVersion 29 and check whether the existing-file handling is affected by scoped storage. Done means the same file can be downloaded again to the same location after deletion without EEXIST.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, flutter, java, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.