fix(sftp): use tar acceleration for pasted directories - #204
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pasting a directory in the SFTP page never used tar acceleration.
buildPasteDepspasseduseTar: falseas a literal (pasteService.ts:113), so copy/paste and cut/paste fell back to per-file SFTP even when both endpoints hadtarand thesftp-tartoggle was on. It also never passed theacceleratedflag torunTransfer, 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: newtarUsableForPair(src, dst)holding the rule "local↔local never tars, otherwise the toggle plustarpresent on every endpoint involved".pasteService.ts:copyTargetresolvesuseTarthrough that helper and passestarget.isDir && useTaras theacceleratedflag.SFTPPage.tsx:executeFilesheld the only copy of that rule inline; it now calls the shared helper.The probe cache in
tarSupport.tsalready dedupes per host, so the added call costs onecommand -v tarper session per host.Destination naming
sftp_download_dir_tar/sftp_upload_dir_tar/sftp_transfer_dir_tarextract 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 indstPath, 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
.tar.gzis staged in the remote/tmpand the local temp dir. A full/tmpnow fails a paste that previously succeeded slowly.tarpreserves permissions, symlinks and timestamps that the per-file path did not.Unchanged for single files, local↔local, FTP endpoints, hosts without
tar, and with thesftp-tartoggle off.Tests
Three cases added to
pasteService.test.tscoveringbuildPasteDeps— 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.