fix(sftp): FIx Permission Denied While Accessing SFTP#1019
fix(sftp): FIx Permission Denied While Accessing SFTP#1019GT-610 merged 4 commits intolollipopkit:mainfrom
Conversation
When the user is not root, set the initial path to `/home/$user`. For root users, use `/root` as the path
| Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds six GitHub participant IDs and changes SFTP page init to asynchronously determine the remote start path from the connected user's home (with fallbacks and optional history override), then triggers directory listing without awaiting it. Changes
Sequence Diagram(s)sequenceDiagram participant UI as SFTP Page (Widget) participant SFTP as SFTP Client participant Hist as History Store participant Status as Path State participant Lister as Directory Lister UI->>SFTP: run "echo ~<user>" alt valid absolute path SFTP-->>UI: home path UI->>Status: compute initPath (home) else invalid or error SFTP-->>UI: error or "~" UI->>Status: compute fallback (/home/<user> or /root) end Hist-->>UI: (if enabled) lastPath UI->>Status: set path = widget.args.initPath ?? initPathOrHistory UI->>Lister: call _listDir() (unawaited) Lister-->>UI: directory listing (async) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)lib/view/**/*.dart📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-10-08T09:36:41.682ZApplied to files:
📚 Learning: 2025-10-08T09:36:41.682ZApplied to files:
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47d875e467
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @coderabbitai In all future pull requests (PRs), please add all participants from the issues resolved by that PR to the |
| Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3003 🏁 Script executed: Length of output: 653
Issue
The PR correctly includes I'll remember to check and propose adding issue participants to the ✏️ Learnings added
|
…chronously processed directory listings Attempt to obtain the user's home directory path by executing a command, and fall back to the default path if it fails. At the same time, change the _listDir call to asynchronous to avoid potential issues.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/view/page/storage/sftp.dart`: - Around line 86-93: The code uses the shell-evaluated homePath from _client.run('eval echo ~${widget.args.spi.user}') without ensuring it's an absolute path; update the logic around homeResult/homePath/initPath to only accept homePath when it is non-empty and begins with '/' (i.e., an absolute path), otherwise fall back to the constructed path using widget.args.spi.user (user != 'root' ? '/home/$user' : '/root'); reference the variables _client.run, homeResult, homePath, initPath, and widget.args.spi.user when making the change. 📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/view/page/storage/sftp.dart
🧰 Additional context used
📓 Path-based instructions (1)
lib/view/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
lib/view/**/*.dart: Prefer widgets/utilities from fl_lib for common UI (e.g., CustomAppBar, context.showRoundDialog, Input, Btnx.cancelOk)
Prefer using libL10n strings before adding new ones to project l10n
Split UI into build, actions, and utils; use extension on to separate concerns
Files:
lib/view/page/storage/sftp.dart
🧠 Learnings (2)
📓 Common learnings
Learnt from: GT-610 Repo: lollipopkit/flutter_server_box PR: 0 File: :0-0 Timestamp: 2026-01-22T05:10:54.484Z Learning: For all future pull requests in the flutter_server_box repository, check if participants from issues resolved by the PR are added to the `participants` field in `lib/data/res/github_id.dart`. If any participants are missing, propose adding them. First verify if they already exist or have been added in the PR commits. Learnt from: CR Repo: lollipopkit/flutter_server_box PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-10-08T09:36:41.682Z Learning: Applies to lib/data/model/sftp/**/*.dart : Place SFTP models under lib/data/model/sftp/ 📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR Repo: lollipopkit/flutter_server_box PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-10-08T09:36:41.682Z Learning: Applies to lib/data/model/sftp/**/*.dart : Place SFTP models under lib/data/model/sftp/ Applied to files:
lib/view/page/storage/sftp.dart
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Change the condition from checking if the path is not equal to '~' to checking if the path starts with '/', to ensure the correct user home directory path is obtained
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/view/page/storage/sftp.dart (1)
82-107: Guard against async gap before invoking_listDir()
afterFirstLayoutawaits a remote command and then calls_listDir(), which usescontext.showLoadingDialog. If the widget is disposed during the await, this can throw. Add amountedguard before using_listDir().🔧 Proposed fix
if (Stores.setting.sftpOpenLastPath.fetch()) { final history = Stores.history.sftpLastPath.fetch(widget.args.spi.id); if (history != null) { initPath = history; } } + if (!mounted) return; _status.path.path = widget.args.initPath ?? initPath; unawaited(_listDir());
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/view/page/storage/sftp.dart
🧰 Additional context used
📓 Path-based instructions (1)
lib/view/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
lib/view/**/*.dart: Prefer widgets/utilities from fl_lib for common UI (e.g., CustomAppBar, context.showRoundDialog, Input, Btnx.cancelOk)
Prefer using libL10n strings before adding new ones to project l10n
Split UI into build, actions, and utils; use extension on to separate concerns
Files:
lib/view/page/storage/sftp.dart
🧠 Learnings (3)
📓 Common learnings
Learnt from: GT-610 Repo: lollipopkit/flutter_server_box PR: 0 File: :0-0 Timestamp: 2026-01-22T05:10:54.484Z Learning: For all future pull requests in the flutter_server_box repository, check if participants from issues resolved by the PR are added to the `participants` field in `lib/data/res/github_id.dart`. If any participants are missing, propose adding them. First verify if they already exist or have been added in the PR commits. Learnt from: CR Repo: lollipopkit/flutter_server_box PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-10-08T09:36:41.682Z Learning: Applies to lib/data/model/sftp/**/*.dart : Place SFTP models under lib/data/model/sftp/ 📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR Repo: lollipopkit/flutter_server_box PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-10-08T09:36:41.682Z Learning: Applies to lib/data/model/sftp/**/*.dart : Place SFTP models under lib/data/model/sftp/ Applied to files:
lib/view/page/storage/sftp.dart
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR Repo: lollipopkit/flutter_server_box PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-10-08T09:36:41.682Z Learning: Applies to lib/data/model/ssh/**/*.dart : Place SSH models under lib/data/model/ssh/ Applied to files:
lib/view/page/storage/sftp.dart
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Resolve #1012.
Summary by CodeRabbit
Chores
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.