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

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

Closed WeinanHu closed 11 months ago

WeinanHu commented 1 year ago

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)

WeinanHu commented 1 year ago

i find the way to solve it:

replace

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

with

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

brendan-duncan commented 11 months ago

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.