clear mount location if in use
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
parent
143a41588f
commit
e3d036fcb8
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import 'package:repertory/helpers.dart' show initialCaps;
|
||||
class MountConfig {
|
||||
bool? mounted;
|
||||
final String _name;
|
||||
String _path = '';
|
||||
String path = '';
|
||||
Map<String, dynamic> _settings = {};
|
||||
final String _type;
|
||||
MountConfig({required name, required type, Map<String, dynamic>? 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<String, dynamic> get settings =>
|
||||
UnmodifiableMapView<String, dynamic>(_settings);
|
||||
@ -28,7 +27,7 @@ class MountConfig {
|
||||
}
|
||||
|
||||
void updateStatus(Map<String, dynamic> status) {
|
||||
_path = status['Location'] as String;
|
||||
path = status['Location'] as String;
|
||||
mounted = status['Active'] as bool;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user