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,
|
||||
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',
|
||||
// );
|
||||
|
||||
// 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,
|
||||
// );
|
||||
|
||||
final bytes = ZipEncoder(
|
||||
password: password,
|
||||
).encode(
|
||||
archive,
|
||||
level: Deflate.BEST_COMPRESSION,
|
||||
)!;
|
||||
// final bytes = ZipEncoder(
|
||||
// password: password,
|
||||
// ).encode(
|
||||
// archive,
|
||||
// level: Deflate.BEST_COMPRESSION,
|
||||
// )!;
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
// 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,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
unawaited(saveFile());
|
||||
// unawaited(saveFile());
|
||||
|
||||
return bytes;
|
||||
// return bytes;
|
||||
}
|
||||
|
||||
Map<String, List<int>> _fetchPackImages(List<GameCardModel> cards) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue