Skip to content

Extract asks before it replaces, like a copy - #117

Merged
2 commits merged into
mainfrom
extract-conflicts
Nov 30, 2026
Merged

2 commits merged into
mainfrom
extract-conflicts

Conversation

@crustovsky

Copy link
Copy Markdown
Owner

Fixes #116.

  • bsdtar unpacks into a hidden staging folder inside the destination; the entries are then moved into place by the item loop a copy uses (now src/core/jobs/engine.h, shared by TransferJob and ExtractJob).
  • Same conflict bar and answers, "for all", merge into existing folders, policy before the start, Unattended list, per-item undo (created items trashed, replaced files restored).
  • Progress from bsdtar -v: current member, bytes, totals from the tab's listing. Pause stops the child, Abort kills it, Skip drops the member in flight.
  • Failures are logged per member where bsdtar names one. Read-only folders from an archive are still placed, with their mode.
  • The staging folder is removed on every exit.

Tests: test_jobs (extractAsksLikeACopy, extractMergesAndKeepsModes, extractSkipPauseAbort, undoPackAndExtract), test_window (extractAsksLikeACopy). ctest passes.

🤖 Generated with Claude Code

crustovsky and others added 2 commits November 30, 2026 20:33
F5 inside an archive ran bsdtar straight into the destination, and
bsdtar replaces what is there: silent data loss, no conflict bar, no
policy for Unattended, one progress step, and an undo record that knew
only the new top-level entries.

bsdtar now unpacks into a hidden staging folder inside the destination
(same filesystem), and the entries are moved into place by the item loop
of a copy. That loop moved out of TransferJob into engine.h so both jobs
drive it; a staged run moves but records what it placed as created, and
names sources by their place in the archive. So an extract gets the
conflict bar with every answer and "for all", merge into folders that
exist, the policy set before the start, Unattended's skip and list, and
an undo that trashes what was placed and restores what was replaced.

While bsdtar runs, -v on a pipe is the progress: the open line names the
member in flight, its size on disk is the current bytes, and the totals
come from the listing the tab has. Pause stops the child (SIGSTOP), Abort
kills it, Skip leaves out the member it was writing (bsdtar cannot be
told, so it is written to the end and then dropped). Failures carry the
member's name where bsdtar gives one. A folder the archive holds
read-only could not be renamed out of the staging folder: it is opened
for the move and gets its mode back where it lands. The staging folder
is removed on every way out.

Fixes #116

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The file is to stay under 350 lines and the jobs paragraph grew by one.
"Extract and pack run bsdtar" still holds; how extract places what it
unpacked is in the headers of extract.h and engine.h.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

Extracting from an archive overwrites existing files without asking

1 participant