feat(backup): tap automatic-backups to make a copy now
This commit is contained in:
parent
7cba4f7fcf
commit
e90a3831f2
4 changed files with 112 additions and 9 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue