mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: sftp upload (#175)
This commit is contained in:
@@ -56,7 +56,7 @@ class ServerStatus {
|
||||
SystemType system;
|
||||
String? err;
|
||||
DiskIO diskIO;
|
||||
List<NvidiaSmiItem>? nvdia;
|
||||
List<NvidiaSmiItem>? nvidia;
|
||||
|
||||
/// Whether is connectting, parsing and etc.
|
||||
bool _isBusy = false;
|
||||
@@ -74,7 +74,7 @@ class ServerStatus {
|
||||
required this.system,
|
||||
required this.diskIO,
|
||||
this.err,
|
||||
this.nvdia,
|
||||
this.nvidia,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -113,8 +113,8 @@ Future<ServerStatus> _getLinuxStatus(ServerStatusUpdateReq req) async {
|
||||
}
|
||||
|
||||
try {
|
||||
final nvdia = NvidiaSmi.fromXml(StatusCmdType.nvdia.find(segments));
|
||||
req.ss.nvdia = nvdia;
|
||||
final nvidia = NvidiaSmi.fromXml(StatusCmdType.nvidia.find(segments));
|
||||
req.ss.nvidia = nvidia;
|
||||
} catch (e, s) {
|
||||
Loggers.parse.warning(e, s);
|
||||
}
|
||||
|
||||
@@ -154,9 +154,12 @@ Future<void> _upload(
|
||||
mainSendPort.send(SftpWorkerStatus.loading);
|
||||
final localFile = local.openRead().cast<Uint8List>();
|
||||
final sftp = await client.sftp();
|
||||
// If remote exists, overwrite it
|
||||
final file = await sftp.open(
|
||||
req.remotePath,
|
||||
mode: SftpFileOpenMode.write | SftpFileOpenMode.create,
|
||||
mode: SftpFileOpenMode.truncate |
|
||||
SftpFileOpenMode.create |
|
||||
SftpFileOpenMode.write,
|
||||
);
|
||||
final writer = file.write(
|
||||
localFile,
|
||||
|
||||
@@ -42,5 +42,7 @@ abstract final class GithubIds {
|
||||
'xingleiwu',
|
||||
'Cooper098',
|
||||
'xushuojie',
|
||||
'AniberMokie',
|
||||
'LucaLin233',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -307,8 +307,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildGpuView(ServerStatus ss) {
|
||||
if (ss.nvdia == null) return UIs.placeholder;
|
||||
final children = ss.nvdia!.map((e) => _buildGpuItem(e)).toList();
|
||||
if (ss.nvidia == null) return UIs.placeholder;
|
||||
final children = ss.nvidia!.map((e) => _buildGpuItem(e)).toList();
|
||||
return CardX(
|
||||
child: ExpandTile(
|
||||
title: const Text('GPU'),
|
||||
|
||||
@@ -144,18 +144,15 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
final remotePath = _status.path?.path;
|
||||
if (remotePath == null) {
|
||||
final remoteDir = _status.path?.path;
|
||||
if (remoteDir == null) {
|
||||
context.showSnackBar('remote path is null');
|
||||
return;
|
||||
}
|
||||
final remotePath = '$remoteDir/${path.split('/').last}';
|
||||
Loggers.app.info('SFTP upload local: $path, remote: $remotePath');
|
||||
Pros.sftp.add(
|
||||
SftpReq(
|
||||
widget.spi,
|
||||
'$remotePath/${path.split('/').last}',
|
||||
path,
|
||||
SftpReqType.upload,
|
||||
),
|
||||
SftpReq(widget.spi, remotePath, path, SftpReqType.upload),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.upload_file));
|
||||
|
||||
@@ -218,7 +218,7 @@ class TagSwitcher extends StatelessWidget implements PreferredSizeWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(_kTagBtnHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user