diff --git a/app/lib/tool/test_profile/import_source.dart b/app/lib/tool/test_profile/import_source.dart index 740d66c1e2..a796b5f710 100644 --- a/app/lib/tool/test_profile/import_source.dart +++ b/app/lib/tool/test_profile/import_source.dart @@ -183,28 +183,22 @@ class ArchiveBuilder { final _entries = []; void addFile(String path, String content) { - final bytes = utf8.encode(content); - _entries.add( - TarEntry( - TarHeader( - name: path, - size: bytes.length, - mode: 420, // 644₈ - ), - Stream>.fromIterable([bytes]), - ), - ); + addFileBytes(path, utf8.encode(content)); } void addFileBytes(String path, List bytes) { + addFileByteChunks(path, [bytes]); + } + + void addFileByteChunks(String path, List> chunks) { _entries.add( TarEntry( TarHeader( name: path, - size: bytes.length, + size: chunks.fold(0, (a, b) => a + b.length), mode: 420, // 644₈ ), - Stream>.fromIterable([bytes]), + Stream>.fromIterable(chunks), ), ); } diff --git a/app/lib/tool/test_profile/importer.dart b/app/lib/tool/test_profile/importer.dart index 5c86570fb7..b17db2fa74 100644 --- a/app/lib/tool/test_profile/importer.dart +++ b/app/lib/tool/test_profile/importer.dart @@ -18,7 +18,6 @@ import '../../fake/backend/fake_auth_provider.dart'; import '../../frontend/handlers/pubapi.client.dart'; import '../../service/async_queue/async_queue.dart'; import '../../shared/configuration.dart'; -import '../../shared/utils.dart'; import '../utils/pub_api_client.dart'; import 'import_source.dart'; import 'models.dart'; @@ -294,14 +293,17 @@ Future> _mayCleanupTarModeBits(List bytes) async { var needsUpdate = false; while (await tarReader.moveNext()) { final current = tarReader.current; - if (current.header.mode != 420) { + if (current.header.mode & 420 != 420) { // 644₈ needsUpdate = true; } - archiveBuilder.addFileBytes( - current.name, - await current.contents.foldBytes(), - ); + if (current.header.typeFlag == TypeFlag.reg || + current.header.typeFlag == TypeFlag.regA) { + archiveBuilder.addFileByteChunks( + current.name, + await current.contents.toList(), + ); + } } return needsUpdate ? archiveBuilder.toTarGzBytes() : bytes; }