Compare commits

..

No commits in common. "ee1638e1dda4437959fc7858dfce348fb455202f" and "b15393bacf109c9915dbd8169c51d558f2ed2949" have entirely different histories.

5 changed files with 8 additions and 32 deletions

View File

@ -168,10 +168,8 @@ 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());
if (this_server != nullptr) { server_->stop();
this_server = nullptr; this_server = nullptr;
server_->stop();
}
} }
handlers::~handlers() { event_system::instance().stop(); } handlers::~handlers() { event_system::instance().stop(); }
@ -365,17 +363,12 @@ 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;
@ -467,7 +460,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 "" /MIN {})", cmd_line).c_str()); system(fmt::format(R"(start "" /b {})", 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)

View File

@ -1,5 +1,4 @@
autofocus autofocus
canvaskit
cupertino cupertino
cupertinoicons cupertinoicons
fromargb fromargb

View File

@ -9,7 +9,6 @@ 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;
@ -78,8 +77,6 @@ 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();
@ -92,13 +89,11 @@ class Mount with ChangeNotifier {
); );
if (response.statusCode == 404) { if (response.statusCode == 404) {
_isMounting = false;
_mountList?.reset(); _mountList?.reset();
return true; return true;
} }
await refresh(force: true); await refresh();
_isMounting = false;
if (!unmount && response.statusCode == 500) { if (!unmount && response.statusCode == 500) {
return false; return false;
@ -107,15 +102,10 @@ class Mount with ChangeNotifier {
debugPrint('$e'); debugPrint('$e');
} }
_isMounting = false;
return true; return true;
} }
Future<void> refresh({bool force = false}) async { Future<void> refresh() async {
if (!force && _isMounting) {
return;
}
await _fetch(); await _fetch();
return _fetchStatus(); return _fetchStatus();
} }
@ -150,7 +140,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/mount_location?name=$name&type=$type', '${getBaseUri()}/api/v1/get_mount_location?name=$name&type=$type',
), ),
), ),
); );
@ -159,8 +149,7 @@ class Mount with ChangeNotifier {
return null; return null;
} }
final location = jsonDecode(response.body)['Location'] as String; return jsonDecode(response.body)['Location'] as String;
return location.trim().isEmpty ? null : location;
} catch (e) { } catch (e) {
debugPrint('$e'); debugPrint('$e');
} }

View File

@ -110,7 +110,7 @@ class _MountWidgetState extends State<MountWidget> {
return cleanup(); return cleanup();
} }
displayErrorMessage(context, "Mount location is not available"); displayErrorMessage(context, "Mount location not found");
return cleanup(); return cleanup();
} }
: null; : null;

View File

@ -33,11 +33,6 @@
<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>