mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
Merge pull request 'fix: Don't let start service migration if the same volume was picked' (#293) from service-migration into master
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/293 Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
commit
8f30c3a4ba
|
@ -55,6 +55,20 @@ class _ServicesMigrationPageState extends State<ServicesMigrationPage> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get isVolumePicked {
|
||||||
|
bool isChangeFound = false;
|
||||||
|
for (final Service service in widget.services) {
|
||||||
|
for (final String serviceId in serviceToDisk.keys) {
|
||||||
|
if (serviceId == service.id &&
|
||||||
|
serviceToDisk[serviceId] != service.storageUsage.volume!) {
|
||||||
|
isChangeFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isChangeFound;
|
||||||
|
}
|
||||||
|
|
||||||
/// Check the services and if a service is moved (in a serviceToDisk entry)
|
/// Check the services and if a service is moved (in a serviceToDisk entry)
|
||||||
/// subtract the used storage from the old volume and add it to the new volume.
|
/// subtract the used storage from the old volume and add it to the new volume.
|
||||||
/// The old volume is the volume the service is currently on, shown in services list.
|
/// The old volume is the volume the service is currently on, shown in services list.
|
||||||
|
@ -157,40 +171,41 @@ class _ServicesMigrationPageState extends State<ServicesMigrationPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
BrandButton.filled(
|
if (widget.isMigration || (!widget.isMigration && isVolumePicked))
|
||||||
child: Text('storage.start_migration_button'.tr()),
|
BrandButton.filled(
|
||||||
onPressed: () {
|
child: Text('storage.start_migration_button'.tr()),
|
||||||
if (widget.isMigration) {
|
onPressed: () {
|
||||||
context.read<ServerJobsCubit>().migrateToBinds(
|
if (widget.isMigration) {
|
||||||
serviceToDisk,
|
context.read<ServerJobsCubit>().migrateToBinds(
|
||||||
);
|
serviceToDisk,
|
||||||
} else {
|
);
|
||||||
for (final service in widget.services) {
|
} else {
|
||||||
if (serviceToDisk[service.id] != null) {
|
for (final service in widget.services) {
|
||||||
context.read<ServicesCubit>().moveService(
|
if (serviceToDisk[service.id] != null) {
|
||||||
service.id,
|
context.read<ServicesCubit>().moveService(
|
||||||
serviceToDisk[service.id]!,
|
service.id,
|
||||||
);
|
serviceToDisk[service.id]!,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
context.router.popUntilRoot();
|
||||||
context.router.popUntilRoot();
|
showModalBottomSheet(
|
||||||
showModalBottomSheet(
|
context: context,
|
||||||
context: context,
|
useRootNavigator: true,
|
||||||
useRootNavigator: true,
|
isScrollControlled: true,
|
||||||
isScrollControlled: true,
|
builder: (final BuildContext context) =>
|
||||||
builder: (final BuildContext context) =>
|
DraggableScrollableSheet(
|
||||||
DraggableScrollableSheet(
|
expand: false,
|
||||||
expand: false,
|
maxChildSize: 0.9,
|
||||||
maxChildSize: 0.9,
|
minChildSize: 0.4,
|
||||||
minChildSize: 0.4,
|
initialChildSize: 0.6,
|
||||||
initialChildSize: 0.6,
|
builder: (final context, final scrollController) =>
|
||||||
builder: (final context, final scrollController) =>
|
JobsContent(controller: scrollController),
|
||||||
JobsContent(controller: scrollController),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue