brendan-duncan/archive

XZDecoder throws LateInitializationError

Closed this issue · 2 comments

I'm using the following line trying to extract a .tar from a .tar.xz:

final result = XZDecoder().decodeBuffer(InputFileStream(fileName));

I receive the following error message:

LateInitializationError: Field '_input@258520520' has already been initialized.
#0      LateError._throwFieldAlreadyInitialized (dart:_internal-patch/internal_patch.dart:194:5)
#1      RangeDecoder._input= (package:archive/src/lzma/range_decoder.dart:33:30)
#2      RangeDecoder.input= (package:archive/src/lzma/range_decoder.dart:45:39)
#3      LzmaDecoder.decode (package:archive/src/lzma/lzma_decoder.dart:142:12)
#4      _XZStreamDecoder._readLZMA2 (package:archive/src/xz_decoder.dart:287:26)
#5      _XZStreamDecoder._readBlock (package:archive/src/xz_decoder.dart:143:5)
#6      _XZStreamDecoder.decode (package:archive/src/xz_decoder.dart:59:7)
#7      XZDecoder.decodeBuffer (package:archive/src/xz_decoder.dart:22:20)
#8      extractFileToDisk (package:archive/src/io/extract_archive_to_disk.dart:94:35)
#9      download (package:generator/src/start_postgrest.dart:17:3)
<asynchronous suspension>
#10     main (file:///Users/arnewolframm/retality/generator/bin/generator.dart:8:3)
<asynchronous suspension>

The file exists and is extracted without problems using tar xJvf my_file.tar.xz on my terminal.

If this is a bug in the archive package, please publish a version that has issue #227 included as soon as possible.

If it is my fault, please kindly explain how I can extract a .tar.xz to disk using archive 3.3.5.

The actual file I'm trying to extract is here: https://github.com/PostgREST/postgrest/releases/download/v10.1.1/postgrest-v10.1.1-macos-x64.tar.xz

Dart SDK version: 2.18.5 (stable) (Tue Nov 22 15:47:29 2022 +0000) on "macos_x64"

#pubspec.yaml
name: generator
description: A sample command-line application.
version: 1.0.0
publish_to: none

environment:
  sdk: '>=2.18.5 <3.0.0'

dependencies:
  path: ^1.8.0
  archive: ^3.3.5

Duplicate of #209

Fix is in 3.3.6