option to restore from backup during onboarding

This commit is contained in:
Fabian Freund
2026-04-18 04:56:03 +02:00
parent dcb0c8d5de
commit 5e6cc7a0f1
8 changed files with 145 additions and 47 deletions
@@ -202,7 +202,7 @@ class UserBackupService extends _$UserBackupService {
}
}
Future<bool> restoreAndCreateNew(
Future<Profile> restoreAndCreateNew(
Uri backupFileUri, {
required String profileName,
required String password,
@@ -222,17 +222,18 @@ class UserBackupService extends _$UserBackupService {
outputDirectory: outputDirectory,
argon2Params: Argon2Params.memoryConstrained(),
);
await backup.unpack(password).then((_) async {
final newProfile = await backup.unpack(password).then((_) async {
final newProfile = Profile.create(name: profileName);
final newPath = filesystem.getProfileDir(newProfile.uuidValue);
await outputDirectory.rename(newPath.path);
await filesystem.updateProfileMetadata(newProfile);
await filesystem.healProfile(newPath);
return newProfile;
});
ref.invalidate(profileRepositoryProvider);
return true;
return newProfile;
} finally {
try {
if (await tempFile.exists()) {
@@ -41,7 +41,7 @@ final class UserBackupServiceProvider
}
}
String _$userBackupServiceHash() => r'3746ae59d490e25a44815c125f30cd0981de555d';
String _$userBackupServiceHash() => r'52c7d3df3ce2d603692a035c77987727b840a359';
abstract class _$UserBackupService extends $Notifier<void> {
void build();