brendan-duncan/archive

Unhandled Exception: FormatException: Could not find End of Central Directory Record

Closed this issue · 2 comments

1.zip
it's show error when i unzip this file, and the zip file has no problem.

device:
iphone 8 plus, ios 14.2
version:
3.3.7
error:
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: FormatException: Could not find End of Central Directory Record
#0 ZipDirectory._findSignature (package:archive/src/zip/zip_directory.dart:149:5)
#1 new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:28:20)
#2 ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:24:30)
#3 extractFileToDisk (package:archive/src/io/extract_archive_to_disk.dart:110:28)
#4 unzipHtmlFile (package:test_editor/util/asset_util.dart:36:9)

i find the way to solve it:

replace

final bytes = File(zipPath).readAsBytesSync();

with

final bytes = await File(zipPath).readAsBytes();

That "fix" doesn't make any sense, both should be the same. I tested the archive and didn't have any issues, so it must be a Dart VM issue.