Compare commits

..

No commits in common. "4a598d00d11fbaad896223390375cd79746cc9b8" and "cc4991e2111983a0fe26c485294de5a1b238f1ff" have entirely different histories.

3 changed files with 20 additions and 27 deletions

View File

@ -210,16 +210,12 @@ void handlers::handle_get_mount_status(auto &&req, auto &&res) const {
void handlers::handle_post_mount(auto &&req, auto &&res) const {
auto type = req.get_param_value("type");
auto name = req.get_param_value("name");
auto location = utils::path::absolute(req.get_param_value("location"));
auto unmount = utils::string::to_bool(req.get_param_value("unmount"));
auto prov = provider_type_from_string(type);
if (unmount) {
read_process(prov, name, "-unmount");
} else {
read_process(prov, name, fmt::format("\"{}\"", location));
}
res.status = http_error_codes::ok;
}

View File

@ -48,11 +48,11 @@ class Mount with ChangeNotifier {
notifyListeners();
}
Future<void> mount(bool unmount, {String? location}) async {
Future<void> mount(bool unmount) async {
await http.post(
Uri.parse(
Uri.encodeFull(
'${Uri.base.origin}/api/v1/mount?unmount=$unmount&name=$name&type=$type&location=$location',
'${Uri.base.origin}/api/v1/mount?unmount=$unmount&name=$name&type=$type',
),
),
);
@ -76,8 +76,4 @@ class Mount with ChangeNotifier {
return refresh();
}
Future<String?> getMountLocation() async {
return "~/mnt/encrypt";
}
}

View File

@ -65,29 +65,30 @@ class _MountWidgetState extends State<MountWidget> {
),
onPressed:
_enabled
? () async {
? () {
setState(() {
_enabled = false;
});
String? location;
if (!isActive) {
location = await mount.getMountLocation();
if (location == null) {}
if (isActive) {
mount
.mount(isActive)
.then((_) {
setState(() {
_enabled = true;
});
})
.catchError((_) {
setState(() {
_enabled = true;
});
});
return;
}
mount
.mount(isActive, location: location)
.then((_) {
setState(() {
_enabled = true;
});
})
.catchError((_) {
setState(() {
_enabled = true;
});
});
setState(() {
_enabled = true;
});
}
: null,
),