err
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions

This commit is contained in:
Dmitry 2025-12-11 22:04:22 +03:00
parent a3a5a55fdc
commit 71c4bc113e

View file

@ -383,52 +383,54 @@ class PackManager {
int userId,
String appVersion,
) async {
final pack = await _fetchPackModel(packId);
try {
final archiveFile = File(
'${assetsDirectory.path}/pack_archives/${appVersion}/${packId}_${pack.version}.zip',
);
if (await archiveFile.exists()) {
return await archiveFile.readAsBytes();
}
} catch (e, s) {
log('Error when fetching pack images archive', error: e, stackTrace: s);
return [];
}
final cards = pack.cards;
final rawData = _fetchPackImages(cards.toList());
final archive = Archive();
for (final entry in rawData.entries) {
archive.addFile(ArchiveFile(entry.key, 0, entry.value));
}
final password = TokenGenerator.generateArchivePassword(
appVersion: appVersion,
id: packId,
);
return [];
// final pack = await _fetchPackModel(packId);
// final archiveFile = File(
// '${assetsDirectory.path}/pack_archives/${appVersion}/${packId}_${pack.version}.zip',
// );
final bytes = ZipEncoder(
password: password,
).encode(
archive,
level: Deflate.BEST_COMPRESSION,
)!;
// try {
// if (await archiveFile.exists()) {
// return await archiveFile.readAsBytes();
// }
// } catch (e, s) {
// log('Error when fetching pack images archive', error: e, stackTrace: s);
// return [];
// }
// final cards = pack.cards;
// final rawData = _fetchPackImages(cards.toList());
// final archive = Archive();
// for (final entry in rawData.entries) {
// archive.addFile(ArchiveFile(entry.key, 0, entry.value));
// }
// final password = TokenGenerator.generateArchivePassword(
// appVersion: appVersion,
// id: packId,
// );
Future<void> saveFile() async {
try {
await archiveFile.create(recursive: true);
await archiveFile.writeAsBytes(bytes);
} catch (e, s) {
log(
'Error when creating archive ${archiveFile.path}',
error: e,
stackTrace: s,
);
}
}
// final bytes = ZipEncoder(
// password: password,
// ).encode(
// archive,
// level: Deflate.BEST_COMPRESSION,
// )!;
unawaited(saveFile());
// Future<void> saveFile() async {
// try {
// await archiveFile.create(recursive: true);
// await archiveFile.writeAsBytes(bytes);
// } catch (e, s) {
// log(
// 'Error when creating archive ${archiveFile.path}',
// error: e,
// stackTrace: s,
// );
// }
// }
return bytes;
// unawaited(saveFile());
// return bytes;
}
Map<String, List<int>> _fetchPackImages(List<GameCardModel> cards) {