InputFileStream not close in extractFileToDisk
Closed this issue · 4 comments
I also have this same problem and I can't find how to fix it :( Were you able to fix it?
I also have this same problem and I can't find how to fix it :( Were you able to fix it?
I just wrote my own imitation of the original function, and close all InputFileStream, and it worked fine. But this is a simplified version that removes some of the original features, such as password support, which is enough for me.
Future<void> extractFileToDisk2(String inputPath, String outputPath) async {
var archivePath = inputPath;
final input = InputFileStream(archivePath);
Archive archive = ZipDecoder().decodeBuffer(input);
for (final file in archive.files) {
final filePath = p.join(outputPath, p.normalize(file.name));
if (!isWithinOutputPath(outputPath, filePath)) {
continue;
}
if (!file.isFile && !file.isSymbolicLink) {
Directory(filePath).createSync(recursive: true);
continue;
}
if (file.isSymbolicLink) {
final link = Link(filePath);
await link.create(p.normalize(file.nameOfLinkedFile), recursive: true);
} else {
final output = File(filePath);
final f = await output.create(recursive: true);
final fp = await f.open(mode: FileMode.write);
final bytes = file.content as List<int>;
await fp.writeFrom(bytes);
file.clear();
await fp.close();
}
}
await archive.clear();
await input.close();
}
Sorry for the long delay, life has been very busy lately. I pushed an update to this on git. I have some other things in this library I've been neglecting lately I wanted to try to get to before pushing a version update.
Sorry for the long delay, life has been very busy lately. I pushed an update to this on git. I have some other things in this library I've been neglecting lately I wanted to try to get to before pushing a version update.
😄It doesn't matter. Thanks a lot. Have a nice day.