brendan-duncan / archive

Dart library to encode and decode various archive and compression formats, such as Zip, Tar, GZip, ZLib, and BZip2.
MIT License
399 stars 139 forks source link

Resource locked after extracting file to disk in windows #252

Open pyjserv opened 1 year ago

pyjserv commented 1 year ago

Hi, I got a problem "Process cannot access the file because it is being used by another process" when I was deleting a zip file after extracting it to disk in windows.

await extractFileToDisk('${path}.zip', '${dirPath}');
File('${path}.zip').deleteSync();

But if I use extractArchiveToDisk() and close inputStream, it works.

final inputStream = InputFileStream('${path}.zip');
final archive = ZipDecoder().decodeBuffer(inputStream);
extractArchiveToDisk(archive, '${dirPath}');
inputStream.close();
File('${path}.zip').deleteSync();

It occurs in my case, and I don't test it in a simple case.