fix: Use latest dartssh2 and add a switch for temperature between celsius and millicelsius (#1095)

* refactor(sftp): Optimize file download logic and SSH command execution handling

Replace manual chunked downloads with a more concise `sftp.download` method
Consistently use `utf8.decode` to process SSH command output

Remove redundant code and comments, and simplify the logic

* chore: Update `dartssh2` submodule

* feat (Temperature Display): Added an option to switch between degrees Celsius and millicelsius

Allows users to switch temperature units in server settings, resolving the issue of incorrect temperature display on some devices

* chore: Add a participnt

* fix(sftp): Fixed a resource leak issue during file downloads and SSH command execution

Ensured that remote and local file handles are properly closed during file downloads to prevent resource leaks. Additionally, improved error handling during SSH command execution to ensure that all streams are either successfully completed or properly handled in the event of an error.
This commit is contained in:
GT610
2026-04-01 11:27:58 +08:00
committed by GitHub
parent 36851ef1c2
commit 3c592baf2c
36 changed files with 211 additions and 102 deletions

View File

@@ -74,6 +74,7 @@ extension _Actions on _ServerEditPageState {
pvePwd: _pvePwdCtrl.text.selfNotEmptyOrNull,
cmds: customCmds.isEmpty ? null : customCmds,
preferTempDev: _preferTempDevCtrl.text.selfNotEmptyOrNull,
tempIsCelsius: _tempIsCelsius.value,
logoUrl: _logoUrlCtrl.text.selfNotEmptyOrNull,
netDev: _netDevCtrl.text.selfNotEmptyOrNull,
scriptDir: _scriptDirCtrl.text.selfNotEmptyOrNull,
@@ -270,6 +271,7 @@ extension _Utils on _ServerEditPageState {
_pvePwdCtrl.text = custom.pvePwd ?? '';
_customCmds.value = custom.cmds ?? {};
_preferTempDevCtrl.text = custom.preferTempDev ?? '';
_tempIsCelsius.value = custom.tempIsCelsius;
_logoUrlCtrl.text = custom.logoUrl ?? '';
}

View File

@@ -70,6 +70,7 @@ class _ServerEditPageState extends ConsumerState<ServerEditPage>
final _autoConnect = ValueNotifier(true);
final _jumpServer = nvn<String?>();
final _pveIgnoreCert = ValueNotifier(false);
final _tempIsCelsius = ValueNotifier(false);
final _env = <String, String>{}.vn;
final _customCmds = <String, String>{}.vn;
final _tags = <String>{}.vn;
@@ -105,6 +106,7 @@ class _ServerEditPageState extends ConsumerState<ServerEditPage>
_autoConnect.dispose();
_jumpServer.dispose();
_pveIgnoreCert.dispose();
_tempIsCelsius.dispose();
_env.dispose();
_customCmds.dispose();
_tags.dispose();

View File

@@ -181,6 +181,18 @@ extension _Widgets on _ServerEditPageState {
hint: 'nvme-pci-0400',
suggestion: false,
),
ListTile(
leading: const Icon(MingCute.question_line),
title: TipText('${libL10n.temperature} (°C)', l10n.tempIsCelsiusTip),
trailing: _tempIsCelsius.listenVal(
(v) => Switch(
value: v,
onChanged: (val) {
_tempIsCelsius.value = val;
},
),
),
).cardx,
Input(
controller: _netDevCtrl,
type: TextInputType.text,