Compare commits
6 Commits
b15393bacf
...
ee1638e1dd
Author | SHA1 | Date | |
---|---|---|---|
ee1638e1dd | |||
d125cb47d6 | |||
16bb4fe472 | |||
984f4e0bc9 | |||
439be1dea8 | |||
c9281c9bcd |
@ -168,8 +168,10 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
||||
event_system::instance().start();
|
||||
|
||||
server_->listen("127.0.0.1", config_->get_api_port());
|
||||
server_->stop();
|
||||
this_server = nullptr;
|
||||
if (this_server != nullptr) {
|
||||
this_server = nullptr;
|
||||
server_->stop();
|
||||
}
|
||||
}
|
||||
|
||||
handlers::~handlers() { event_system::instance().stop(); }
|
||||
@ -363,12 +365,17 @@ void handlers::handle_post_mount(auto &&req, auto &&res) const {
|
||||
if (unmount) {
|
||||
launch_process(prov, name, "-unmount");
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
if (utils::file::directory{location}.exists()) {
|
||||
#else // !defined(_WIN32)
|
||||
if (not utils::file::directory{location}.exists()) {
|
||||
#endif // defined(_WIN32)
|
||||
res.status = http_error_codes::internal_error;
|
||||
return;
|
||||
}
|
||||
|
||||
launch_process(prov, name, fmt::format(R"("{}")", location), true);
|
||||
config_->set_mount_location(prov, name, location);
|
||||
}
|
||||
|
||||
res.status = http_error_codes::ok;
|
||||
@ -460,7 +467,7 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
|
||||
recur_mutex_lock inst_lock(inst_mtx);
|
||||
if (background) {
|
||||
#if defined(_WIN32)
|
||||
system(fmt::format(R"(start "" /b {})", cmd_line).c_str());
|
||||
system(fmt::format(R"(start "" /MIN {})", cmd_line).c_str());
|
||||
#elif defined(__linux__) // defined(__linux__)
|
||||
system(fmt::format("nohup {} 1>/dev/null 2>&1", cmd_line).c_str());
|
||||
#else // !defined(__linux__) && !defined(_WIN32)
|
||||
|
@ -1,4 +1,5 @@
|
||||
autofocus
|
||||
canvaskit
|
||||
cupertino
|
||||
cupertinoicons
|
||||
fromargb
|
||||
|
@ -9,6 +9,7 @@ import 'package:repertory/types/mount_config.dart';
|
||||
class Mount with ChangeNotifier {
|
||||
final MountConfig mountConfig;
|
||||
final MountList? _mountList;
|
||||
bool _isMounting = false;
|
||||
Mount(this.mountConfig, this._mountList, {isAdd = false}) {
|
||||
if (isAdd) {
|
||||
return;
|
||||
@ -77,6 +78,8 @@ class Mount with ChangeNotifier {
|
||||
|
||||
Future<bool> mount(bool unmount, {String? location}) async {
|
||||
try {
|
||||
_isMounting = true;
|
||||
|
||||
mountConfig.mounted = null;
|
||||
notifyListeners();
|
||||
|
||||
@ -89,11 +92,13 @@ class Mount with ChangeNotifier {
|
||||
);
|
||||
|
||||
if (response.statusCode == 404) {
|
||||
_isMounting = false;
|
||||
_mountList?.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
await refresh();
|
||||
await refresh(force: true);
|
||||
_isMounting = false;
|
||||
|
||||
if (!unmount && response.statusCode == 500) {
|
||||
return false;
|
||||
@ -102,10 +107,15 @@ class Mount with ChangeNotifier {
|
||||
debugPrint('$e');
|
||||
}
|
||||
|
||||
_isMounting = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
Future<void> refresh({bool force = false}) async {
|
||||
if (!force && _isMounting) {
|
||||
return;
|
||||
}
|
||||
|
||||
await _fetch();
|
||||
return _fetchStatus();
|
||||
}
|
||||
@ -140,7 +150,7 @@ class Mount with ChangeNotifier {
|
||||
final response = await http.get(
|
||||
Uri.parse(
|
||||
Uri.encodeFull(
|
||||
'${getBaseUri()}/api/v1/get_mount_location?name=$name&type=$type',
|
||||
'${getBaseUri()}/api/v1/mount_location?name=$name&type=$type',
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -149,7 +159,8 @@ class Mount with ChangeNotifier {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonDecode(response.body)['Location'] as String;
|
||||
final location = jsonDecode(response.body)['Location'] as String;
|
||||
return location.trim().isEmpty ? null : location;
|
||||
} catch (e) {
|
||||
debugPrint('$e');
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class _MountWidgetState extends State<MountWidget> {
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
displayErrorMessage(context, "Mount location not found");
|
||||
displayErrorMessage(context, "Mount location is not available");
|
||||
return cleanup();
|
||||
}
|
||||
: null;
|
||||
|
@ -33,6 +33,11 @@
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
window.flutterConfiguration = {
|
||||
canvasKitBaseUrl: "/canvaskit/"
|
||||
};
|
||||
</script>
|
||||
<script src="flutter_bootstrap.js" async></script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user