Skip to content

Enhancing SFTP timeout handling#1216

Merged
GT-610 merged 4 commits into
mainfrom
opt/sftp
Jun 29, 2026
Merged

Enhancing SFTP timeout handling#1216
GT-610 merged 4 commits into
mainfrom
opt/sftp

Conversation

@GT-610

@GT-610 GT-610 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added shared SFTP timeout handling and enhanced transfer state tracking.
    • Improved local path generation with safer remote-path sanitization.
  • Bug Fixes
    • SFTP timeouts now surface clearer, operation-specific errors.
    • Directory listing and session restoration are more reliable under slow/failed connections.
    • Missing timestamps now display as - instead of the Unix epoch.
  • Refactor
    • Unified SFTP chunk sizing across downloads and uploads and streamlined transfer lifecycle/disposal behavior.
    • Updated SFTP mission/status screens to use the improved transfer-state flow and removed the “unknown” fallback UI path.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e9b5a8a7-096d-4056-9515-f0e3cc968e23

📥 Commits

Reviewing files that changed from the base of the PR and between 5ce4c1f and f978172.

📒 Files selected for processing (4)
  • lib/core/utils/sftp_timeout.dart
  • lib/data/model/sftp/status.dart
  • lib/data/model/sftp/worker.dart
  • lib/view/page/storage/sftp.dart
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/data/model/sftp/status.dart
  • lib/view/page/storage/sftp.dart
  • lib/data/model/sftp/worker.dart

📝 Walkthrough

Walkthrough

The PR adds shared SFTP timeout helpers, extracts SftpReqStatus into status.dart, and refactors SftpWorker to use unified chunk sizing plus per-operation timeout wrappers. It updates provider and page imports to the split SFTP modules, changes SFTP storage-page timeout and delete flows, sanitizes derived local paths, and adjusts mission/helper UI behavior for null status and null timestamps.

Possibly related PRs

Suggested reviewers

  • lollipopkit
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: improved SFTP timeout handling across the worker and UI flows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch opt/sftp

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot requested a review from lollipopkit June 29, 2026 03:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 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/core/utils/sftp_timeout.dart`:
- Around line 14-19: The timeout wrapper in sftp_timeout.dart only rethrows a
TimeoutException and logs it, but the browser-session open flow in the SFTP open
path can time out before a SftpClient exists, leaving the underlying open
operation without cleanup. Update the open logic that calls _client.sftp() so it
either avoids wrapping the session-open future in timeout or wires a
cancellation/close path into the timeout handling, and make sure the cleanup is
tied to the SftpClient/session open code path rather than only to later
file/session close callers.

In `@lib/data/model/sftp/status.dart`:
- Around line 31-33: The SftpStatus constructor is firing `worker.init()`
without handling its async failure path, so initialization errors can be lost
and the request may never complete. Update the constructor/`SftpWorker` setup so
the `init` call is observed and any failure is caught and routed through the
existing request/status error handling path, using the `SftpStatus` and
`SftpWorker.init` symbols to locate the affected flow.
- Around line 41-44: The SFTP status cleanup in dispose() is not idempotent, so
repeated calls can hit completer?.complete(true) more than once and throw.
Update the Status.dispose method to guard against double disposal by checking
whether the completer has already been completed or by clearing/marking the
state after the first completion, while still disposing the worker exactly once.

In `@lib/view/page/storage/sftp.dart`:
- Around line 929-939: The _safeLocalPathPart helper in Sftp page path
construction only blocks traversal tokens and the platform separator, but it
still lets platform-invalid or reserved filename values through. Update the
remotePath-to-local-path mapping in the same code path to sanitize all invalid
characters and reserved device names for local filesystems, not just "."/".."
and Pfs.seperator, so downloads can be safely written on Windows and other
platforms. Keep the fix centered around _safeLocalPathPart and the pathParts
fold that builds the local path.
- Around line 743-744: The confirmation text built in the SFTP delete flow no
longer warns that directories may be removed recursively when
Stores.setting.sftpRmrDir.fetch() is already enabled. Update the message
construction around useRmr and libL10n.askContinue in the delete path so it
always includes recursive-delete wording for directory deletions, even when the
checkbox is hidden, and keep the confirmation copy aligned with the rm -r / sudo
recursive delete behavior.
🪄 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: cdfbb78f-8c57-45a7-a1e0-e6ba2afa4f6f

📥 Commits

Reviewing files that changed from the base of the PR and between c74175a and 5ce4c1f.

📒 Files selected for processing (9)
  • lib/core/utils/sftp_timeout.dart
  • lib/data/model/sftp/req.dart
  • lib/data/model/sftp/status.dart
  • lib/data/model/sftp/worker.dart
  • lib/data/provider/sftp.dart
  • lib/view/page/storage/local.dart
  • lib/view/page/storage/sftp.dart
  • lib/view/page/storage/sftp_helpers.dart
  • lib/view/page/storage/sftp_mission.dart

Comment thread lib/core/utils/sftp_timeout.dart
Comment thread lib/data/model/sftp/status.dart
Comment thread lib/data/model/sftp/status.dart
Comment thread lib/view/page/storage/sftp.dart Outdated
Comment thread lib/view/page/storage/sftp.dart
@GT-610 GT-610 changed the title Opt/sftp Enhancing SFTP timeout handling Jun 29, 2026
@GT-610 GT-610 merged commit 5484183 into main Jun 29, 2026
3 checks passed
@GT-610 GT-610 deleted the opt/sftp branch June 29, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant