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,
|
void handle_post_add_mount(const httplib::Request &req,
|
||||||
httplib::Response &res) const;
|
httplib::Response &res) const;
|
||||||
|
|
||||||
void handle_post_mount(const httplib::Request &req,
|
void handle_post_mount(const httplib::Request &req, httplib::Response &res);
|
||||||
httplib::Response &res) const;
|
|
||||||
|
|
||||||
void handle_put_set_value_by_name(const httplib::Request &req,
|
void handle_put_set_value_by_name(const httplib::Request &req,
|
||||||
httplib::Response &res) const;
|
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,
|
void handlers::handle_post_mount(const httplib::Request &req,
|
||||||
httplib::Response &res) const {
|
httplib::Response &res) {
|
||||||
auto name = req.get_param_value("name");
|
auto name = req.get_param_value("name");
|
||||||
auto prov = provider_type_from_string(req.get_param_value("type"));
|
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)
|
#else // !defined(_WIN32)
|
||||||
if (not utils::file::directory{location}.exists()) {
|
if (not utils::file::directory{location}.exists()) {
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
config_->set_mount_location(prov, name, "");
|
||||||
res.status = http_error_codes::internal_error;
|
res.status = http_error_codes::internal_error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -181,10 +181,6 @@ void mgmt_app_config::set_mount_location(provider_type prov,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
recur_mutex_lock lock(mtx_);
|
recur_mutex_lock lock(mtx_);
|
||||||
if (locations_[prov][std::string{name}] == std::string{location}) {
|
if (locations_[prov][std::string{name}] == std::string{location}) {
|
||||||
return;
|
return;
|
||||||
|
@ -163,12 +163,15 @@ class Mount with ChangeNotifier {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final badLocation = (!unmount && response.statusCode == 500);
|
||||||
|
if (badLocation) {
|
||||||
|
mountConfig.path = "";
|
||||||
|
}
|
||||||
|
|
||||||
await refresh(force: true);
|
await refresh(force: true);
|
||||||
_isMounting = false;
|
_isMounting = false;
|
||||||
|
|
||||||
if (!unmount && response.statusCode == 500) {
|
return !badLocation;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('$e');
|
debugPrint('$e');
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import 'package:repertory/helpers.dart' show initialCaps;
|
|||||||
class MountConfig {
|
class MountConfig {
|
||||||
bool? mounted;
|
bool? mounted;
|
||||||
final String _name;
|
final String _name;
|
||||||
String _path = '';
|
String path = '';
|
||||||
Map<String, dynamic> _settings = {};
|
Map<String, dynamic> _settings = {};
|
||||||
final String _type;
|
final String _type;
|
||||||
MountConfig({required name, required type, Map<String, dynamic>? settings})
|
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 bucket => _settings['${provider}Config']?["Bucket"] as String;
|
||||||
String get name => _name;
|
String get name => _name;
|
||||||
String get path => _path;
|
|
||||||
String get provider => initialCaps(_type);
|
String get provider => initialCaps(_type);
|
||||||
UnmodifiableMapView<String, dynamic> get settings =>
|
UnmodifiableMapView<String, dynamic> get settings =>
|
||||||
UnmodifiableMapView<String, dynamic>(_settings);
|
UnmodifiableMapView<String, dynamic>(_settings);
|
||||||
@ -28,7 +27,7 @@ class MountConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateStatus(Map<String, dynamic> status) {
|
void updateStatus(Map<String, dynamic> status) {
|
||||||
_path = status['Location'] as String;
|
path = status['Location'] as String;
|
||||||
mounted = status['Active'] as bool;
|
mounted = status['Active'] as bool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user