mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-17 22:44:34 +01:00
fix(ssh): Modify the return type of execWithPwd to include the output content
Adjust the return type of the `execWithPwd` method to `(int?, String)` so that it can simultaneously return the exit code and output content Fix the issue in ContainerNotifier where the return result of execWithPwd is not handled correctly Ensure that server operations (shutdown/restart/suspend) are correctly pending until the command execution is completed
This commit is contained in:
@@ -84,15 +84,14 @@ class ContainerNotifier extends _$ContainerNotifier {
|
||||
}
|
||||
final includeStats = Stores.setting.containerParseStat.fetch();
|
||||
|
||||
var raw = '';
|
||||
final cmd = _wrap(ContainerCmdType.execAll(state.type, sudo: sudo, includeStats: includeStats));
|
||||
final code = await client?.execWithPwd(
|
||||
cmd,
|
||||
context: context,
|
||||
onStdout: (data, _) => raw = '$raw$data',
|
||||
id: hostId,
|
||||
);
|
||||
int? code;
|
||||
String raw = '';
|
||||
if (client != null) {
|
||||
(code, raw) = await client!.execWithPwd(cmd, context: context, id: hostId);
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isBusy: false);
|
||||
|
||||
if (!context.mounted) return;
|
||||
@@ -234,7 +233,7 @@ class ContainerNotifier extends _$ContainerNotifier {
|
||||
|
||||
state = state.copyWith(runLog: '');
|
||||
final errs = <String>[];
|
||||
final code = await client?.execWithPwd(
|
||||
final (code, _) = await client?.execWithPwd(
|
||||
_wrap((await sudoCompleter.future) ? 'sudo -S $cmd' : cmd),
|
||||
context: context,
|
||||
onStdout: (data, _) {
|
||||
@@ -242,7 +241,7 @@ class ContainerNotifier extends _$ContainerNotifier {
|
||||
},
|
||||
onStderr: (data, _) => errs.add(data),
|
||||
id: hostId,
|
||||
);
|
||||
) ?? (null, null);
|
||||
state = state.copyWith(runLog: null);
|
||||
|
||||
if (code != 0) {
|
||||
|
||||
Reference in New Issue
Block a user