brendan-duncan/archive

Resource locked after extracting file to disk in windows

Opened this issue · 0 comments

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.