Skip to content

fix(sftp): use tar acceleration for pasted directories - #204

Merged
kipavy merged 1 commit into
devfrom
fix/paste-tar-acceleration
Sep 1, 2026
Merged

fix(sftp): use tar acceleration for pasted directories#204
kipavy merged 1 commit into
devfrom
fix/paste-tar-acceleration

Conversation

@kipavy

@kipavy kipavy commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Pasting a directory in the SFTP page never used tar acceleration. buildPasteDeps passed useTar: false as a literal (pasteService.ts:113), so copy/paste and cut/paste fell back to per-file SFTP even when both endpoints had tar and the sftp-tar toggle was on. It also never passed the accelerated flag to runTransfer, so the badge could not appear.

Drag-and-drop between the panes did use tar (SFTPPage.executeFiles). The same directory therefore transferred fast or slow depending on which gesture the user picked, with nothing in the UI explaining the difference. On a directory of many small files the gap is an order of magnitude over a high-latency link.

Found while investigating a user report of a missing acceleration badge. That report turned out to be a different, expected case — the remote was an FTP connection, which has no SSH exec channel, so tar is structurally unavailable there (src-tauri/src/sftp/mod.rs:139). This bug was found alongside it.

Change

  • tarSupport.ts: new tarUsableForPair(src, dst) holding the rule "local↔local never tars, otherwise the toggle plus tar present on every endpoint involved".
  • pasteService.ts: copyTarget resolves useTar through that helper and passes target.isDir && useTar as the accelerated flag.
  • SFTPPage.tsx: executeFiles held the only copy of that rule inline; it now calls the shared helper.

The probe cache in tarSupport.ts already dedupes per host, so the added call costs one command -v tar per session per host.

Destination naming

sftp_download_dir_tar / sftp_upload_dir_tar / sftp_transfer_dir_tar extract into the destination path with --strip-components=1, so the paste path's collision renaming (saves - Copy) is preserved — the extracted directory takes the name in dstPath, not the archive's.

Scope

Multi-item pastes still tar per item rather than batching into one archive like drag-and-drop's execBatchTar. Paste renames each item individually on collision, while batch tar drops the original names into the destination directory; unifying them needs the collision path reworked first.

Behaviour changes users will see

  • Progress tracks the archive rather than individual files, so the bar sits still during remote compression and extraction. Already true of drag-and-drop; new for the paste path.
  • A .tar.gz is staged in the remote /tmp and the local temp dir. A full /tmp now fails a paste that previously succeeded slowly.
  • All-or-nothing: a mid-transfer failure leaves nothing extracted instead of a partial set. Cut/paste still only deletes the source after a successful copy.
  • tar preserves permissions, symlinks and timestamps that the per-file path did not.

Unchanged for single files, local↔local, FTP endpoints, hosts without tar, and with the sftp-tar toggle off.

Tests

Three cases added to pasteService.test.ts covering buildPasteDeps — directory with a tar-capable pair, a pair that cannot tar, and a single file never flagged accelerated. Red before the change, green after.

vitest run: 521 files, 3988 tests passed. tsc --noEmit: clean.

Pasting a directory hardcoded `useTar: false`, so copy/paste and cut/paste
always fell back to per-file SFTP even when both endpoints supported tar, and
never flagged the transfer as accelerated. Drag-and-drop between the panes did
use tar, so the same transfer was fast or slow depending on the gesture.

Extract the "local<->local never tars, otherwise the toggle plus tar on every
endpoint" rule into `tarUsableForPair` and call it from both the paste path and
`SFTPPage.executeFiles`, which held the only copy of it.
@kipavy
kipavy merged commit d06c73c into dev Sep 1, 2026
4 checks passed
@kipavy
kipavy deleted the fix/paste-tar-acceleration branch September 1, 2026 18:35
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