starkdmi / download_manager

Isolated download manager with progress, cancellation, pause and resume
https://pub.dev/packages/isolated_download_manager
BSD 3-Clause "New" or "Revised" License
15 stars 2 forks source link

PathAccessException in windows #9

Open Hamid313-coder opened 4 months ago

Hamid313-coder commented 4 months ago

When I want to cancel a download in my flutter windows app, I receive this error: [ERROR:flutter/runtime/dart_isolate.cc(1097)] Unhandled exception: PathAccessException: Cannot delete file, path = 'C:\Users\HAMID\AppData\Local\Temp/lesson2.zip' (OS Error: The process cannot access the file because it is being used by another process.

I guess maybe the file or file path is used by another isolate, so the access to file to delete it is denied.

starkdmi commented 4 months ago

Hi, @Hamid313-coder, do you get the same error running this example app?

Probably, the reason is a missing sink.close() on cancel and error states in download_task package. The sink object is initialised here and there is a line of code for closing it on success.

I have no Flutter/Dart setup at the moment, neither a Windows device, but there were no issues on macOS & iOS.