make sftpworker upload/download action handle single file

This commit is contained in:
RafayAhmad7548 2025-08-14 06:22:05 +05:00
parent 33ade0479f
commit 075003f1ad
3 changed files with 77 additions and 89 deletions

View file

@ -216,23 +216,17 @@ class _SftpExplorerState extends State<SftpExplorer> {
final files = await openFiles();
filePaths = files.map((file) => file.path).toList();
}
try {
bool start = true;
await for (final progress in widget.sftpWorker.uploadFiles(path, filePaths)) {
if (start) {
start = false;
_listDir();
}
setState(() => _uploadProgress = progress);
if (progress == 1) {
// TODO: fix: next file also starts to show
_listDir();
for (final filePath in filePaths) {
try {
await for (final progress in widget.sftpWorker.uploadFile(path, filePath)) {
setState(() => _uploadProgress = progress);
}
await _listDir();
}
}
catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.toString()));
catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(buildErrorSnackBar(context, e.toString()));
}
}
}
setState(() => _uploadProgress = null);