diff --git a/repertory/repertory/include/ui/handlers.hpp b/repertory/repertory/include/ui/handlers.hpp index d049fea2..31ce7d59 100644 --- a/repertory/repertory/include/ui/handlers.hpp +++ b/repertory/repertory/include/ui/handlers.hpp @@ -92,8 +92,7 @@ private: void handle_post_add_mount(const httplib::Request &req, httplib::Response &res) const; - void handle_post_mount(const httplib::Request &req, - httplib::Response &res) const; + void handle_post_mount(const httplib::Request &req, httplib::Response &res); void handle_put_set_value_by_name(const httplib::Request &req, httplib::Response &res) const; diff --git a/repertory/repertory/src/ui/handlers.cpp b/repertory/repertory/src/ui/handlers.cpp index 70592762..0de3484e 100644 --- a/repertory/repertory/src/ui/handlers.cpp +++ b/repertory/repertory/src/ui/handlers.cpp @@ -480,7 +480,7 @@ void handlers::handle_post_add_mount(const httplib::Request &req, } void handlers::handle_post_mount(const httplib::Request &req, - httplib::Response &res) const { + httplib::Response &res) { auto name = req.get_param_value("name"); auto prov = provider_type_from_string(req.get_param_value("type")); @@ -500,6 +500,7 @@ void handlers::handle_post_mount(const httplib::Request &req, #else // !defined(_WIN32) if (not utils::file::directory{location}.exists()) { #endif // defined(_WIN32) + config_->set_mount_location(prov, name, ""); res.status = http_error_codes::internal_error; return; } diff --git a/repertory/repertory/src/ui/mgmt_app_config.cpp b/repertory/repertory/src/ui/mgmt_app_config.cpp index bb2704cc..c088cfdf 100644 --- a/repertory/repertory/src/ui/mgmt_app_config.cpp +++ b/repertory/repertory/src/ui/mgmt_app_config.cpp @@ -181,10 +181,6 @@ void mgmt_app_config::set_mount_location(provider_type prov, return; } - if (location.empty()) { - return; - } - recur_mutex_lock lock(mtx_); if (locations_[prov][std::string{name}] == std::string{location}) { return; diff --git a/web/repertory/lib/models/mount.dart b/web/repertory/lib/models/mount.dart index 0bceb2a0..81bed08a 100644 --- a/web/repertory/lib/models/mount.dart +++ b/web/repertory/lib/models/mount.dart @@ -163,12 +163,15 @@ class Mount with ChangeNotifier { return true; } + final badLocation = (!unmount && response.statusCode == 500); + if (badLocation) { + mountConfig.path = ""; + } + await refresh(force: true); _isMounting = false; - if (!unmount && response.statusCode == 500) { - return false; - } + return !badLocation; } catch (e) { debugPrint('$e'); } diff --git a/web/repertory/lib/types/mount_config.dart b/web/repertory/lib/types/mount_config.dart index 8a6a10d1..631d4c7d 100644 --- a/web/repertory/lib/types/mount_config.dart +++ b/web/repertory/lib/types/mount_config.dart @@ -4,7 +4,7 @@ import 'package:repertory/helpers.dart' show initialCaps; class MountConfig { bool? mounted; final String _name; - String _path = ''; + String path = ''; Map _settings = {}; final String _type; MountConfig({required name, required type, Map? settings}) @@ -17,7 +17,6 @@ class MountConfig { String? get bucket => _settings['${provider}Config']?["Bucket"] as String; String get name => _name; - String get path => _path; String get provider => initialCaps(_type); UnmodifiableMapView get settings => UnmodifiableMapView(_settings); @@ -28,7 +27,7 @@ class MountConfig { } void updateStatus(Map status) { - _path = status['Location'] as String; + path = status['Location'] as String; mounted = status['Active'] as bool; } }