Compare commits

...

6 Commits

Author SHA1 Message Date
ee1638e1dd return null
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-03-17 13:51:09 -05:00
d125cb47d6 fix route 2025-03-17 13:35:08 -05:00
16bb4fe472 mount status fix 2025-03-17 13:18:36 -05:00
984f4e0bc9 windows fixes 2025-03-17 13:08:01 -05:00
439be1dea8 windows fixes 2025-03-17 12:54:38 -05:00
c9281c9bcd windows fixes 2025-03-17 12:50:16 -05:00
5 changed files with 32 additions and 8 deletions

View File

@ -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)

View File

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

View File

@ -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');
}

View File

@ -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;

View File

@ -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>