deansyd / icloud_storage

A flutter plugin for uploading and downloading files to and from iCloud
MIT License
42 stars 24 forks source link

Download hangs after first time #6

Closed aleripe closed 3 years ago

aleripe commented 3 years ago

Download hangs at line 227, where StreamHandler is created, but only the second time the same file is downloaded:

let dwonloadStreamHandler = StreamHandler()
dwonloadStreamHandler.onCancelHandler = { [self] in
   removeObservers(query)
   query.stop()
}

Any idea?

aleripe commented 3 years ago

I've done some more investigations. It's not necessarily the second time, it could be also the first or the tenth. But it doesn't always work. I've seen the problem happens more frequently after an upload.

deansyd commented 3 years ago

Hi @aleripe, could you please describe what exactly is the problem? You've mentioned 'download hangs', what does that mean? The file is not downloading or the progress doesn't show up in the stream?

aleripe commented 3 years ago

Hi, both! File is not downloading and there's no progress on the stream either. If I put a breakpoint on that line (let dwonloadStreamHandler = StreamHandler()) it stops and then doesn't go on. That leads me to suppose the problem is on the StreamHandler, but I'm sort of a newbie in Flutter so I don't want to swear on it.

Thanks for this great package!

aleripe commented 3 years ago

I was wrong with my previous message... it hangs on line 277:

try FileManager.default.copyItem(at: cloudFileURL, to: localFileURL)

and doesn't get into the catch block either.

aleripe commented 3 years ago

Not sure if this can help you, but I'm able to download a file only if I do it right after iCloudStorage.startDownload without using the onProgress callback that is never called and doesn't fire any update.

deansyd commented 3 years ago

I couldn't gather enough information from your comments to fully understand the issue you are experiencing. But I just pushed an update to fix two known issues (https://pub.dev/packages/icloud_storage/changelog). The fix may be related to your issues.

aleripe commented 3 years ago

Thanks! Can't wait to try the fix... iCloud sync is the last thing missing from my app. I'll let you know if this solves my problem, too. Again, thank you!

aleripe commented 3 years ago

You're my hero. The problem is solved with the latest update, so it seems I was into one of the two issues! Thank you sooooo much!!