initial pwa + custom tabs
This commit is contained in:
@@ -62,6 +62,12 @@ class ProfileRepository extends _$ProfileRepository {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clean up Mozilla cache directories before deleting the profile
|
||||
final mozillaProfileIds = filesystem.getMozillaProfileIds(uuid);
|
||||
for (final profileId in mozillaProfileIds) {
|
||||
await filesystem.clearMozillaProfileCache(profileId);
|
||||
}
|
||||
|
||||
await filesystem.getProfileDir(uuid).delete(recursive: true);
|
||||
|
||||
ref.invalidateSelf();
|
||||
|
||||
@@ -33,7 +33,7 @@ final class ProfileRepositoryProvider
|
||||
ProfileRepository create() => ProfileRepository();
|
||||
}
|
||||
|
||||
String _$profileRepositoryHash() => r'249240ce0e775d4fd9ee3558e6b05326d09d79de';
|
||||
String _$profileRepositoryHash() => r'e925dba74b0f15244fea8fff8391b5b67509be09';
|
||||
|
||||
abstract class _$ProfileRepository extends $AsyncNotifier<List<Profile>> {
|
||||
FutureOr<List<Profile>> build();
|
||||
|
||||
@@ -51,6 +51,8 @@ class UserBackupService extends _$UserBackupService {
|
||||
Stream<File> getBackupListStream() async* {
|
||||
final backupDirectory = await getBackupDirectory();
|
||||
|
||||
if (!await backupDirectory.exists()) return;
|
||||
|
||||
await for (final entity in backupDirectory.list(recursive: true)) {
|
||||
if (entity is File) {
|
||||
yield entity;
|
||||
@@ -144,32 +146,49 @@ class UserBackupService extends _$UserBackupService {
|
||||
final existingProfile = await filesystem.readProfileMetadata(
|
||||
outputDirectory,
|
||||
);
|
||||
if (existingProfile != null) {
|
||||
if (existingProfile.uuidValue == filesystem.selectedProfile) {
|
||||
throw Exception(
|
||||
'Unable to override active User, please switch to another User and try again',
|
||||
);
|
||||
}
|
||||
|
||||
final profileDir = filesystem.getProfileDir(
|
||||
existingProfile.uuidValue,
|
||||
if (existingProfile == null) {
|
||||
throw Exception(
|
||||
'Backup does not contain valid profile metadata',
|
||||
);
|
||||
}
|
||||
|
||||
if (await profileDir.exists()) {
|
||||
final result = await confirmOverrideCallback();
|
||||
if (existingProfile.uuidValue == filesystem.selectedProfile) {
|
||||
throw Exception(
|
||||
'Unable to override active User, please switch to another User and try again',
|
||||
);
|
||||
}
|
||||
|
||||
if (result == true) {
|
||||
await profileDir.delete(recursive: true);
|
||||
await outputDirectory.rename(profileDir.path);
|
||||
}
|
||||
final profileDir = filesystem.getProfileDir(
|
||||
existingProfile.uuidValue,
|
||||
);
|
||||
|
||||
if (await profileDir.exists()) {
|
||||
final result = await confirmOverrideCallback();
|
||||
|
||||
if (result == true) {
|
||||
await profileDir.delete(recursive: true);
|
||||
await outputDirectory.rename(profileDir.path);
|
||||
}
|
||||
} else {
|
||||
// Profile doesn't exist yet, just move the restored data into place
|
||||
await outputDirectory.rename(profileDir.path);
|
||||
}
|
||||
});
|
||||
|
||||
ref.invalidate(profileRepositoryProvider);
|
||||
return true;
|
||||
} finally {
|
||||
await outputDirectory.delete(recursive: true);
|
||||
try {
|
||||
if (await outputDirectory.exists()) {
|
||||
await outputDirectory.delete(recursive: true);
|
||||
}
|
||||
} catch (e, s) {
|
||||
logger.w(
|
||||
'Failed to cleanup temporary backup directory: ${outputDirectory.path}',
|
||||
error: e,
|
||||
stackTrace: s,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ final class UserBackupServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$userBackupServiceHash() => r'cbeffa04bb52d3c7d50a2eb38678750f2a0362cc';
|
||||
String _$userBackupServiceHash() => r'a0bcf458e6b0a982f1fc90fce99e60cc3418f4d9';
|
||||
|
||||
abstract class _$UserBackupService extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
Reference in New Issue
Block a user