improve zip

This commit is contained in:
2024-12-17 12:10:57 +08:00
parent b6cccb7749
commit b49e0974ab
3 changed files with 9 additions and 13 deletions

View File

@@ -1,5 +1,4 @@
import 'dart:convert';
import 'dart:isolate';
import 'package:venera/foundation/app.dart';
import 'package:venera/foundation/comic_type.dart';
@@ -63,7 +62,7 @@ abstract class CBZ {
var cache = Directory(FilePath.join(App.cachePath, 'cbz_import'));
if (cache.existsSync()) cache.deleteSync(recursive: true);
cache.createSync();
await Isolate.run(() => ZipFile.openAndExtract(file.path, cache.path));
await ZipFile.openAndExtractAsync(file.path, cache.path, 4);
var metaDataFile = File(FilePath.join(cache.path, 'metadata.json'));
ComicMetaData? metaData;
if (metaDataFile.existsSync()) {
@@ -208,13 +207,13 @@ abstract class CBZ {
).toJson(),
),
);
var cbz = File(FilePath.join(App.cachePath, '${comic.title}.cbz'));
var cbz = File(FilePath.join(App.cachePath, sanitizeFileName('${comic.title}.cbz')));
await _compress(cache.path, cbz.path);
cache.deleteSync(recursive: true);
return cbz;
}
static _compress(String src, String dst) async {
await Isolate.run(() => ZipFile.compressFolder(src, dst));
await ZipFile.compressFolderAsync(src, dst, 4);
}
}

View File

@@ -1125,12 +1125,11 @@ packages:
zip_flutter:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: d5721f1fd8179ee4a5db59f932ae7c89d94e12a0
url: "https://github.com/wgh136/zip_flutter"
source: git
version: "0.0.1"
name: zip_flutter
sha256: "72b85f84dc5737e1c1dd7ed97ed0242f397872acc8d03044a5789b466dbf42b2"
url: "https://pub.dev"
source: hosted
version: "0.0.2"
sdks:
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"

View File

@@ -51,9 +51,7 @@ dependencies:
sliver_tools: ^0.2.12
flutter_file_dialog: ^3.0.2
file_selector: ^1.0.3
zip_flutter:
git:
url: https://github.com/wgh136/zip_flutter
zip_flutter: ^0.0.2
lodepng_flutter:
git:
url: https://github.com/venera-app/lodepng_flutter