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