fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
906 stars 508 forks source link

[SQLiteDatabase] Error inserting bucket_id #310

Open EArminjon opened 4 years ago

EArminjon commented 4 years ago

I've an issue when downloading file : sometimes i got in my logcat (not into the running console)

2020-06-10 14:29:25.350 17502-17515/android.process.media E/SQLiteDatabase: Error inserting bucket_id=1424065491 date_modified=1591792165 datetaken=1591792165348 bucket_display_name=packages parent=58 format=12299 storage_id=65537 mime_type=video/mp4 media_type=3 _size=8641108 description= title=5eda550887f67_gopr1493.mp4 _data=/storage/emulated/0/Android/data/net.beyondGravity/files/skydivingCentre/packages/5eda550887f67_gopr1493.mp4 date_added=1591792165 _display_name=5eda550887f67_gopr1493.mp4
    android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: files._data (code 2067)
        at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
        at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782)
        at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
        at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
        at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1474)
        at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1343)
        at com.android.providers.media.MediaProvider.insertFile(MediaProvider.java:3282)
        at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:3600)
        at com.android.providers.media.MediaProvider.insert(MediaProvider.java:2920)
        at android.content.ContentProvider$Transport.insert(ContentProvider.java:264)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:163)
        at android.os.Binder.execTransact(Binder.java:565)

What happen if several FlutterDownloader.enqueue() are called in same time ?

EArminjon commented 4 years ago

Actually to prevent downloading twice same task i check state with :

String query = "SELECT * FROM task WHERE file_name='$fileName' and saved_dir='$outputPath'";
    List<DownloadTask> tasks = await FlutterDownloader.loadTasksWithRawQuery(query: query);

But issue above freeze the download of some files...

EArminjon commented 4 years ago

Up

mminhlequang commented 3 years ago

@hnvn please check issue

sh4msi commented 2 years ago

@hnvn +

felipecastrosales commented 9 months ago

any alternatives for this? I'm facing with this problem after delete item from file manager and try make download again in my app.