mnemo_cards/mnemo_cards_backend/lib/cron/delete_old_archives.dart
Dmitry 550b56276e
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Mobile App CI / test (push) Waiting to run
Mobile App CI / build-android (push) Blocked by required conditions
Mobile App CI / build-ios (push) Blocked by required conditions
Web App CI / test (push) Waiting to run
Web App 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
Deploy Telegram Bot / Deploy Telegram Bot (push) Waiting to run
postgress fix
2025-12-13 23:55:50 +03:00

54 lines
1.5 KiB
Dart

import 'dart:developer';
import 'dart:io';
import 'package:mnemo_cards_backend/cron/task.dart';
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
import 'package:mnemo_cards_backend/packs/pack_manager.dart';
import '../main.dart';
import 'package:path/path.dart';
class DeleteOldArchives with Task {
@override
String get name => 'delete_old_archives';
@override
Future<void> task() async {
return;
// final archives =
// (await Directory('${PackManager.assetsDirectory.path}/pack_archives')
// .list(recursive: true)
// .toList())
// .whereType<File>();
// final packs = await isar.cardPackModels.where().findAll();
// final toDelete = <File>[];
// for (final pack in packs) {
// try {
// for (final archive in archives) {
// final names = basename(archive.path).split('_');
// if (names.first == pack.id?.toString() &&
// names.last != pack.version) {
// toDelete.add(archive);
// }
// }
// } catch (e) {
// print('$name on pack ${pack.id}: $e');
// }
// }
// try {
// for (final file in toDelete) {
// await file.delete();
// }
// } catch (e, s) {
// log(
// 'Error when deleting packs',
// error: e,
// stackTrace: s,
// );
// }
// print('deleted ${toDelete.length} old archives');
}
@override
int get intervalSeconds => 60 * 60 * 3;
}