Skip to content

refactor(file-browser): Consolidate rename logic and error handling - #2958

Open
AuDevTist1C wants to merge 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:refactor/file-browser-dedupe-rename
Open

AuDevTist1C wants to merge 1 commit into
Acode-Foundation:mainfrom
AuDevTist1C:refactor/file-browser-dedupe-rename

Conversation

@AuDevTist1C

Copy link
Copy Markdown
Contributor

This PR refactors the file/folder rename control flow in fileBrowser.js to eliminate code duplication across standard and Termux storage backends while unifying asynchronous error handling.


Changes

1. Refactor and Deduplicate renameFile Flow

  • Consolidated the execution pipeline in renameFile(newname) following the DRY (Don't Repeat Yourself) design principle.
  • Before: The Termux branch (isTermuxUrl(url)) maintained duplicate state updates (recents.removeFile, recents.addFile, editorManager.getFile, openFolder.renameItem, toast, and reload()) and exited early via return statements.
  • After: Both Termux and standard filesystem paths resolve newUrl within a unified if / else block. Successful executions fall through to a single, centralized set of state updates and UI refreshes.

2. Unified Error Handling

  • Wrapped standard filesystem operations (fs.renameTo(newname)) inside the master try...catch block to handle exceptions consistently alongside Termux operations.

(PR name and description are AI generated (Gemini 3.6 Flash))

… handling

- Unify post-rename side effects (recents update, editor tab URI sync, tree state, success toast, reload) across standard and Termux filesystem paths.
- Wrap standard filesystem rename execution inside the master try-catch block to gracefully capture errors.

(AI generated commit message)
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refactors file rename logic and error handling.

This PR appears safe to merge.

What we checked:

  • Rename updates stay correct: Both supported branches assign newUrl as before. Unsupported Termux directories return before the shared updates.

Summary

renameFile now shares one set of updates for Termux and standard storage.

  • Both branches keep their existing rename operations and destination URLs.
  • Backend selection and file operations now sit inside one error handler.
  • No actionable issues found.

Reviews (1) · Last reviewed commit: "refactor(file-browser): Deduplicate `ren..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant