feat(backup): tap automatic-backups to make a copy now

This commit is contained in:
vjrj 2026-07-10 11:05:36 +02:00
parent 7cba4f7fcf
commit e90a3831f2
4 changed files with 112 additions and 9 deletions

View file

@ -45,10 +45,19 @@ class AutoBackupService {
/// a backup must never crash startup or the move to the background).
Future<bool> runIfDue({Duration interval = const Duration(days: 7)}) async {
try {
final now = _now();
final last = await _store.lastBackupAt();
if (last != null && now.difference(last) < interval) return false;
if (last != null && _now().difference(last) < interval) return false;
} on Object {
return false;
}
return backupNow();
}
/// Makes a copy right now, ignoring the schedule for an explicit "back up
/// now" tap. Returns true on success, false on any failure (never throws).
Future<bool> backupNow() async {
try {
final now = _now();
final dir = await _directory();
await dir.create(recursive: true);
final sealed = await _exporter.buildSealedBackup();