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:
GT610
2026-01-11 22:03:02 +08:00
parent 06070c29b9
commit 0659e7f9d0
3 changed files with 26 additions and 23 deletions

View File

@@ -112,7 +112,7 @@ extension SSHClientX on SSHClient {
return (session, result.takeBytes().string);
}
Future<int?> execWithPwd(
Future<(int?, String)> execWithPwd(
String script, {
String? entry,
BuildContext? context,
@@ -121,7 +121,7 @@ extension SSHClientX on SSHClient {
required String id,
}) async {
var isRequestingPwd = false;
final (session, _) = await exec(
final (session, output) = await exec(
(sess) {
sess.stdin.add('$script\n'.uint8List);
sess.stdin.close();
@@ -147,7 +147,7 @@ extension SSHClientX on SSHClient {
onStdout: onStdout,
entry: entry,
);
return session.exitCode;
return (session.exitCode, output);
}
Future<String> execForOutput(