mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
improve zip
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:isolate';
|
|
||||||
|
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
import 'package:venera/foundation/comic_type.dart';
|
import 'package:venera/foundation/comic_type.dart';
|
||||||
@@ -63,7 +62,7 @@ abstract class CBZ {
|
|||||||
var cache = Directory(FilePath.join(App.cachePath, 'cbz_import'));
|
var cache = Directory(FilePath.join(App.cachePath, 'cbz_import'));
|
||||||
if (cache.existsSync()) cache.deleteSync(recursive: true);
|
if (cache.existsSync()) cache.deleteSync(recursive: true);
|
||||||
cache.createSync();
|
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'));
|
var metaDataFile = File(FilePath.join(cache.path, 'metadata.json'));
|
||||||
ComicMetaData? metaData;
|
ComicMetaData? metaData;
|
||||||
if (metaDataFile.existsSync()) {
|
if (metaDataFile.existsSync()) {
|
||||||
@@ -208,13 +207,13 @@ abstract class CBZ {
|
|||||||
).toJson(),
|
).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);
|
await _compress(cache.path, cbz.path);
|
||||||
cache.deleteSync(recursive: true);
|
cache.deleteSync(recursive: true);
|
||||||
return cbz;
|
return cbz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static _compress(String src, String dst) async {
|
static _compress(String src, String dst) async {
|
||||||
await Isolate.run(() => ZipFile.compressFolder(src, dst));
|
await ZipFile.compressFolderAsync(src, dst, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
pubspec.lock
11
pubspec.lock
@@ -1125,12 +1125,11 @@ packages:
|
|||||||
zip_flutter:
|
zip_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
name: zip_flutter
|
||||||
ref: HEAD
|
sha256: "72b85f84dc5737e1c1dd7ed97ed0242f397872acc8d03044a5789b466dbf42b2"
|
||||||
resolved-ref: d5721f1fd8179ee4a5db59f932ae7c89d94e12a0
|
url: "https://pub.dev"
|
||||||
url: "https://github.com/wgh136/zip_flutter"
|
source: hosted
|
||||||
source: git
|
version: "0.0.2"
|
||||||
version: "0.0.1"
|
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.6.0 <4.0.0"
|
dart: ">=3.6.0 <4.0.0"
|
||||||
flutter: ">=3.27.0"
|
flutter: ">=3.27.0"
|
||||||
|
@@ -51,9 +51,7 @@ dependencies:
|
|||||||
sliver_tools: ^0.2.12
|
sliver_tools: ^0.2.12
|
||||||
flutter_file_dialog: ^3.0.2
|
flutter_file_dialog: ^3.0.2
|
||||||
file_selector: ^1.0.3
|
file_selector: ^1.0.3
|
||||||
zip_flutter:
|
zip_flutter: ^0.0.2
|
||||||
git:
|
|
||||||
url: https://github.com/wgh136/zip_flutter
|
|
||||||
lodepng_flutter:
|
lodepng_flutter:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/venera-app/lodepng_flutter
|
url: https://github.com/venera-app/lodepng_flutter
|
||||||
|
Reference in New Issue
Block a user