flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

Flutter downloader not loading tasks in ios

Open noeljayson opened this issue 2 years ago • 17 comments

After downloading the file the plugin does not load the the tasks .

FlutterDownloader.loadTasks() not loading downloaded tasks or its progress

List<DownloadTask>? getTasks = await FlutterDownloader.loadTasks();

it shows empty it works in android but not working in ios simulator

noeljayson avatar Jan 05 '23 06:01 noeljayson

@noeljayson did it work on a previous version?

markst avatar Jan 06 '23 05:01 markst

No it's not working in previous version

noeljayson avatar Jan 06 '23 05:01 noeljayson

Hi, 3 2 1

Im with the same problem. On android everything is working fine

brunoda6 avatar Jan 06 '23 11:01 brunoda6

Hi,I have the same problem, in iOS

Memet18 avatar Jan 09 '23 12:01 Memet18

Is this issue solved in lastest update I don't have Mac to test

noeljayson avatar Jan 12 '23 06:01 noeljayson

Need to dig deeper, but from what I can gather the sqlite3_open is failing with the error "unable to open database file" returned from sqlite3_errmsg.

https://github.com/fluttercommunity/flutter_downloader/blob/master/ios/Classes/DBManager.m#L101

markst avatar Jan 13 '23 00:01 markst

“download_tasks.sql” couldn’t be moved to “Application Support” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.

I think this is due to NSApplicationSupportDirectory not existing initially and needs to be created:

[[NSFileManager defaultManager] createDirectoryAtPath:self.appDirectory withIntermediateDirectories:true attributes:nil error:&error];

https://stackoverflow.com/questions/16204988/ios-cant-save-file-to-application-support-folder-but-can-to-documents

markst avatar Jan 13 '23 00:01 markst

Is this issue solved in lastest update I don't have Mac to test

@noeljayson yes, solved

Memet18 avatar Jan 13 '23 11:01 Memet18

Is this issue solved in lastest update I don't have Mac to test

@noeljayson yes, solved

No bro i have tested it yesterday it is not loading tasks it is showing empty

noeljayson avatar Jan 15 '23 16:01 noeljayson

Hi, I've found the flutter_downloader to be comprehensive, but also a bit buggy, so I wrote a much simpler download package background_downloader. Have a look and see if it serves your needs.

781flyingdutchman avatar Jan 24 '23 01:01 781flyingdutchman

Is this issue solved in lastest update I don't have Mac to test

@noeljayson yes, solved

No bro i have tested it yesterday it is not loading tasks it is showing empty

I found the solution, is a problem in the newer update, they added a variable allowCellular, when doing a FlutterDownloader.enqueue() you need to set it inside mandatory if you use loadTasksWithRawQuery, is probably a missing implementation as for loadTasks it is not needed. So just add allowCellular: true and it will work.

lucaantonelli avatar Jan 27 '23 09:01 lucaantonelli

Is this issue solved in lastest update I don't have Mac to test

@noeljayson yes, solved

No bro i have tested it yesterday it is not loading tasks it is showing empty

I found the solution, is a problem in the newer update, they added a variable allowCellular, when doing a FlutterDownloader.enqueue() you need to set it inside mandatory if you use loadTasksWithRawQuery, is probably a missing implementation as for loadTasks it is not needed. So just add allowCellular: true and it will work.

Didn't quite understand your solution, in the FlutterDownloader.enqueue() constructor, "enable cellular" is set to true by default.

Memet18 avatar Jan 27 '23 10:01 Memet18

I made a PR to solve the issue: #803 In the latest update they solved the problem for loadTasks but didn't made the implementation for loadTasksWithRawQuery, I solved by editing my local pub cache for now with the code in the PR.

lucaantonelli avatar Jan 27 '23 10:01 lucaantonelli

@lucaantonelli I don't understand either. I call enqueue and receive an ID, but there are no tasks coming back regardless if I call loadTasksWithRawQuery or loadTasks.

XCode has console messages saying that the db table couldn't be created/opened:

2023-01-27 14:41:14.409124-0500 Runner[91608:2755010] [logging-persist] cannot open file at line 46846 of [554764a6e7]
2023-01-27 14:41:14.409272-0500 Runner[91608:2755010] [logging-persist] os_unix.c:46847: (0) open(/Users/daveshirman/Library/Developer/CoreSimulator/Devices/87E9B360-9F79-4769-B51C-50A6D4C130D0/data/Containers/Data/Application/DF3B920F-C0D4-49F0-ABAB-A7C00DCC6D4E/Library/Application Support/download_tasks.sql) - Undefined error: 0
2023-01-27 14:41:15.019091-0500 Runner[91608:2755978] [logging-persist] cannot open file at line 46846 of [554764a6e7]
2023-01-27 14:41:15.019338-0

How did you solve this with version 1.10.1+2?

daveshirman avatar Jan 27 '23 19:01 daveshirman

@daveshirman Maybe i have confused something. I solved a problem where loadTasksWithRawQuery show an error when called if allowCellular was not set. About your problem of the tasks table not getting created, is something i have struggled with too in the last week, probably something related with the #728 and #757 where they moved the database from public folder to app folder. I will check if i find a solution, for now in my app i switched to open_filex plugin for opening file, i know this isn't a solution.

lucaantonelli avatar Jan 30 '23 08:01 lucaantonelli

Same issue.

iOS DB is invalid absolutely on FlutterDownloader ^1.9.1. iOS can't open file download_tasks.sql, the file may never be created successfully.

Problem occurred with DB migration before?

jackleemeta avatar Feb 10 '23 03:02 jackleemeta

any update on this? I can still see that loadTasks() returns [] sometimes, and sometimes it returns the value. Why is this disimilarities. I am on version: flutter_downloader: ^1.11.5 by the time of pasting this issue. image

You can see in my console i mostly get this: image

meshivanshsinghh avatar Dec 15 '23 15:12 meshivanshsinghh