fix mounting across multiple instances
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-19 08:13:14 -05:00
parent 901000a085
commit bced895ea1
3 changed files with 34 additions and 27 deletions

View File

@ -46,8 +46,12 @@ namespace {
} }
for (auto &[prov, map] : map_of_maps) { for (auto &[prov, map] : map_of_maps) {
for (const auto &[key, value] : auto prov_str = repertory::provider_type_to_string(prov);
json[repertory::provider_type_to_string(prov)].items()) { if (!json.contains(prov_str)) {
continue;
}
for (const auto &[key, value] : json.at(prov_str).items()) {
map[key] = value; map[key] = value;
} }
} }

View File

@ -85,6 +85,29 @@ class Mount with ChangeNotifier {
} }
} }
Future<String?> getMountLocation() async {
try {
final response = await http.get(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/mount_location?name=$name&type=$type',
),
),
);
if (response.statusCode != 200) {
return null;
}
final location = jsonDecode(response.body)['Location'] as String;
return location.trim().isEmpty ? null : location;
} catch (e) {
debugPrint('$e');
}
return null;
}
Future<bool> mount(bool unmount, {String? location}) async { Future<bool> mount(bool unmount, {String? location}) async {
try { try {
_isMounting = true; _isMounting = true;
@ -166,27 +189,4 @@ class Mount with ChangeNotifier {
debugPrint('$e'); debugPrint('$e');
} }
} }
Future<String?> getMountLocation() async {
try {
final response = await http.get(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/mount_location?name=$name&type=$type',
),
),
);
if (response.statusCode != 200) {
return null;
}
final location = jsonDecode(response.body)['Location'] as String;
return location.trim().isEmpty ? null : location;
} catch (e) {
debugPrint('$e');
}
return null;
}
} }

View File

@ -109,13 +109,16 @@ class _MountWidgetState extends State<MountWidget> {
final success = await mount.mount(mounted, location: location); final success = await mount.mount(mounted, location: location);
if (success || if (success ||
mount.mounted! || mounted ||
constants.navigatorKey.currentContext == null || constants.navigatorKey.currentContext == null ||
!constants.navigatorKey.currentContext!.mounted) { !constants.navigatorKey.currentContext!.mounted) {
return cleanup(); return cleanup();
} }
displayErrorMessage(context, "Mount location is not available"); displayErrorMessage(
context,
"Mount location is not available: $location",
);
cleanup(); cleanup();
} }
: null; : null;