SFTP download fix && Format#1172
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughThis PR contains: (1) an SFTP download implementation switching from downloadTo to a segmented ranged-read loop with smaller read chunk size, single pending request, per-read timeouts, and progress updates; (2) ServerNotifier changes introducing _usePersistentShellForStatus, updateClient reset, and _runStatusCommand/_runStatusCommandWithExec with timeout fallback to exec; (3) a repository-wide set of formatting/line-wrapping refactors across many Dart files and tests; and (4) bump of the packages/dartssh2 submodule pointer. Possibly related PRs
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
lib/data/model/sftp/worker.dart (1)
184-184: ⚡ Quick winUse request-configured timeout instead of a hardcoded 30s read timeout.
Line 184 hardcodes read timeout and ignores
req.timeoutSeconds, making transfer behavior inconsistent with prepare-time timeout handling. Consider deriving it from request config for predictable tuning.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/data/model/sftp/worker.dart` at line 184, The hardcoded Duration(seconds: 30) used in the .timeout call should be replaced with the request-configured timeout value so transfer respects req.timeoutSeconds; update the .timeout(...) invocation to derive the duration from req.timeoutSeconds (e.g., Duration(seconds: req.timeoutSeconds ?? <sensible_default>)) and ensure you handle null/zero values and enforce a reasonable minimum to avoid indefinite or too-short timeouts — change the .timeout call that currently uses Duration(seconds: 30) to use req.timeoutSeconds and add validation fallback logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/data/model/sftp/worker.dart`:
- Around line 171-202: The loop advances offset by the requested variable length
instead of the actual bytes received, which can skip data; update the logic in
the while loop that reads from openedRemoteFile.read(...) so that after each
segment you compute the actual bytesRead for that segment by summing
chunk.length values consumed (use the existing chunk loop/totalBytes tracking or
a local segmentBytes variable), then set offset += bytesRead; if bytesRead == 0
(no data returned for a requested segment) throw a SftpError('Download returned
0 bytes at offset=$offset') to fail fast and avoid silent corruption; ensure you
still keep totalBytes and chunkCount updated from chunk.length.
In `@lib/data/provider/server/single.dart`:
- Around line 564-575: _runStatusCommandWithExec currently awaits
client.run(statusCmd) with no timeout, which can hang; wrap the exec call in a
timeout (e.g. await client.run(statusCmd).timeout(Duration(seconds: X)) or use
the SSHClient run method's timeout parameter if available) and handle
TimeoutException by returning a suitable SSHDecoder.decode input or a
short-circuit error string so status refresh won't block; keep the rest of the
function intact (references: _runStatusCommandWithExec, client.run, statusCmd,
isWindows, SSHDecoder.decode, spi.name).
---
Nitpick comments:
In `@lib/data/model/sftp/worker.dart`:
- Line 184: The hardcoded Duration(seconds: 30) used in the .timeout call should
be replaced with the request-configured timeout value so transfer respects
req.timeoutSeconds; update the .timeout(...) invocation to derive the duration
from req.timeoutSeconds (e.g., Duration(seconds: req.timeoutSeconds ??
<sensible_default>)) and ensure you handle null/zero values and enforce a
reasonable minimum to avoid indefinite or too-short timeouts — change the
.timeout call that currently uses Duration(seconds: 30) to use
req.timeoutSeconds and add validation fallback logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2b85dd92-2c34-4ea9-af42-d81de77be296
📒 Files selected for processing (101)
lib/app.dartlib/core/chan.dartlib/core/extension/server.dartlib/core/extension/ssh_client.dartlib/core/service/ssh_discovery.dartlib/core/utils/comparator.dartlib/core/utils/host_key_helper.dartlib/core/utils/server_dedup.dartlib/core/utils/ssh_auth.dartlib/core/utils/ssh_config.dartlib/data/helper/ssh_decoder.dartlib/data/helper/system_detector.dartlib/data/model/ai/ask_ai_models.dartlib/data/model/app/bak/backup.dartlib/data/model/app/bak/backup2.dartlib/data/model/app/bak/backup_service.dartlib/data/model/app/net_view.dartlib/data/model/app/scripts/cmd_types.dartlib/data/model/app/scripts/script_builders.dartlib/data/model/app/scripts/script_consts.dartlib/data/model/app/scripts/shell_func.dartlib/data/model/container/image.dartlib/data/model/container/ps.dartlib/data/model/server/amd.dartlib/data/model/server/battery.dartlib/data/model/server/conn.dartlib/data/model/server/connection_stat.dartlib/data/model/server/custom.dartlib/data/model/server/discovery_result.dartlib/data/model/server/disk_smart.dartlib/data/model/server/memory.dartlib/data/model/server/net_speed.dartlib/data/model/server/nvdia.dartlib/data/model/server/ping_result.dartlib/data/model/server/port_forward.dartlib/data/model/server/private_key_info.dartlib/data/model/server/pve.dartlib/data/model/server/sensors.dartlib/data/model/server/server_status_update_req.dartlib/data/model/server/system.dartlib/data/model/server/time_seq.dartlib/data/model/server/windows_parser.dartlib/data/model/server/wol_cfg.dartlib/data/model/sftp/worker.dartlib/data/model/ssh/virtual_key.dartlib/data/provider/container.dartlib/data/provider/private_key.dartlib/data/provider/server/single.dartlib/data/provider/sftp.dartlib/data/provider/snippet.dartlib/data/provider/systemd.dartlib/data/res/github_id.dartlib/data/res/store.dartlib/data/ssh/session_manager.dartlib/data/store/container.dartlib/data/store/history.dartlib/data/store/port_forward.dartlib/data/store/private_key.dartlib/data/store/setting.dartlib/data/store/snippet.dartlib/intro.dartlib/main.dartlib/view/page/home.dartlib/view/page/iperf.dartlib/view/page/port_forward.dartlib/view/page/private_key/edit.dartlib/view/page/private_key/list.dartlib/view/page/server/discovery/discovery.dartlib/view/page/server/discovery/widget.dartlib/view/page/server/tab/card_stat.dartlib/view/page/server/tab/content.dartlib/view/page/server/tab/landscape.dartlib/view/page/server/tab/tab.dartlib/view/page/server/tab/top_bar.dartlib/view/page/server/tab/utils.dartlib/view/page/setting/entries/ssh.dartlib/view/page/setting/platform/platform_pub.dartlib/view/page/setting/seq/srv_func_seq.dartlib/view/page/snippet/edit.dartlib/view/page/ssh/page/init.dartlib/view/page/ssh/page/virt_key.dartlib/view/page/ssh/tab.dartlib/view/page/storage/sftp_mission.dartlib/view/page/systemd.dartlib/view/widget/omit_start_text.dartmake.dartpackages/dartssh2test/amd_smi_test.darttest/container_test.darttest/core_utils_test.darttest/disabled_cmd_types_test.darttest/net_speed_test.darttest/script_builder_test.darttest/server_dedup_test.darttest/server_edit_logic_test.darttest/server_status_update_req_test.darttest/ssh_config_test.darttest/system_dist_test.darttest/terminal_output_buffer_test.darttest/uptime_test.darttest/windows_test.dart
💤 Files with no reviewable changes (1)
- lib/view/page/ssh/tab.dart
Summary by CodeRabbit
Bug Fixes
Improvements
Code Quality
Tests