Compare commits

..

No commits in common. "b93e2978b0239ad8704d0a27d8b651a766d7641a" and "7605be809c0da9e52437616ddf71e97d5c94e39d" have entirely different histories.

3 changed files with 17 additions and 45 deletions

View File

@ -334,7 +334,6 @@ void handlers::handle_post_mount(auto &&req, auto &&res) const {
} else {
if (not utils::file::directory{location}.exists()) {
res.status = http_error_codes::internal_error;
return;
}
launch_process(prov, name, fmt::format(R"("{}")", location), true);

View File

@ -2,7 +2,6 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:repertory/constants.dart' as constants;
import 'package:repertory/helpers.dart';
import 'package:repertory/models/mount_list.dart';
import 'package:repertory/types/mount_config.dart';
@ -74,9 +73,9 @@ class Mount with ChangeNotifier {
}
}
Future<bool> mount(bool unmount, {String? location}) async {
Future<void> mount(bool unmount, {String? location}) async {
try {
final response = await http.post(
await http.post(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/mount?unmount=$unmount&name=$name&type=$type&location=$location',
@ -84,16 +83,10 @@ class Mount with ChangeNotifier {
),
);
if (!unmount && response.statusCode == 500) {
return false;
}
await refresh();
return refresh();
} catch (e) {
debugPrint('$e');
}
return true;
}
Future<void> refresh() async {

View File

@ -4,7 +4,6 @@ import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:repertory/constants.dart' as constants;
import 'package:repertory/helpers.dart';
import 'package:repertory/models/mount.dart';
@ -141,15 +140,9 @@ class _MountWidgetState extends State<MountWidget> {
}
}
cleanup() {
setState(() {
_enabled = true;
});
}
if (location == null) {
if (!context.mounted) {
return cleanup();
return;
}
ScaffoldMessenger.of(context).showSnackBar(
@ -160,34 +153,21 @@ class _MountWidgetState extends State<MountWidget> {
),
),
);
return cleanup();
return;
}
final success = await mount.mount(
isActive,
location: location,
);
if (success ||
isActive ||
constants.navigatorKey.currentContext == null ||
!constants.navigatorKey.currentContext!.mounted) {
return cleanup();
}
ScaffoldMessenger.of(
constants.navigatorKey.currentContext!,
).showSnackBar(
SnackBar(
content: const Text(
"Mount location not found",
textAlign: TextAlign.center,
),
),
);
return cleanup();
mount
.mount(isActive, location: location)
.then((_) {
setState(() {
_enabled = true;
});
})
.catchError((_) {
setState(() {
_enabled = true;
});
});
}
: null,
),