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
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:
parent
a3a5a55fdc
commit
71c4bc113e
1 changed files with 44 additions and 42 deletions
|
|
@ -383,52 +383,54 @@ class PackManager {
|
||||||
int userId,
|
int userId,
|
||||||
String appVersion,
|
String appVersion,
|
||||||
) async {
|
) 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 [];
|
return [];
|
||||||
}
|
// final pack = await _fetchPackModel(packId);
|
||||||
final cards = pack.cards;
|
// final archiveFile = File(
|
||||||
final rawData = _fetchPackImages(cards.toList());
|
// '${assetsDirectory.path}/pack_archives/${appVersion}/${packId}_${pack.version}.zip',
|
||||||
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,
|
|
||||||
);
|
|
||||||
|
|
||||||
final bytes = ZipEncoder(
|
// try {
|
||||||
password: password,
|
// if (await archiveFile.exists()) {
|
||||||
).encode(
|
// return await archiveFile.readAsBytes();
|
||||||
archive,
|
// }
|
||||||
level: Deflate.BEST_COMPRESSION,
|
// } 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 {
|
// final bytes = ZipEncoder(
|
||||||
try {
|
// password: password,
|
||||||
await archiveFile.create(recursive: true);
|
// ).encode(
|
||||||
await archiveFile.writeAsBytes(bytes);
|
// archive,
|
||||||
} catch (e, s) {
|
// level: Deflate.BEST_COMPRESSION,
|
||||||
log(
|
// )!;
|
||||||
'Error when creating archive ${archiveFile.path}',
|
|
||||||
error: e,
|
|
||||||
stackTrace: s,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
Map<String, List<int>> _fetchPackImages(List<GameCardModel> cards) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue