Skip to content

fix: keep the previous repository copy when a download fails part way - #192

Merged
ehennestad merged 1 commit into
mainfrom
fix-download-keeps-previous-copy-on-failure
Sep 11, 2026
Merged

ehennestad merged 1 commit into
mainfrom
fix-download-keeps-previous-copy-on-failure

Conversation

@ehennestad

Copy link
Copy Markdown
Collaborator

Fixes #187.

Problem

downloadRepository removed the existing repository folder and then copied the unzipped download into its place. A copy that failed part way, from a full disk or an interrupted job, left a folder that exists but holds only part of the library: isfolder passes, some version folders are there and others are not, and everything downstream reports those versions as holding no instances.

One correction to the issue as filed: copyfile does throw when called without outputs, so a failed copy was not recorded as the current commit. What was wrong is the order, the previous copy was deleted before the new one was complete, and that a partial copy could not be told from a whole one.

Fix

The extraction is its own function, openminds.internal.utility.git.extractRepositoryArchive. It unzips into a staging folder beside the repository folder, on the same volume, so that putting the result in place is a rename rather than a second copy of 17,000 files, and only then removes the previous copy and moves the new one over. An extraction that fails leaves the previous copy untouched, and the staging folder is removed whether or not it succeeded. The one-folder layout of a GitHub archive is checked before anything is touched and reported as OPENMINDS:Git:UnexpectedArchiveLayout; a move that fails is reported as OPENMINDS:Git:MoveFailed with the message from the OS. The commit is recorded after the move, as before.

What remains: between removing the previous copy and renaming the new one into place there is no copy on disk. That window is two operations on sibling folders, not a copy of every file.

Tests

GitDownloadTest gains three tests against local archives, no network: the previous copy is replaced rather than merged into and nothing of the staging folder remains; a damaged archive leaves the previous copy untouched; an archive that does not hold one folder is rejected by identifier before the previous copy is touched. The existing download test is unchanged.

🤖 Generated with Claude Code

downloadRepository removed the existing repository folder before the
new one was complete, so a copy that failed part way left a folder
that exists but holds only part of the library, and every downstream
check took it for a whole one.

The extraction is now its own function, extractRepositoryArchive. It
unzips into a staging folder beside the repository folder, checks the
one-folder layout of a GitHub archive, and only then removes the
previous copy and renames the new one into place. A failed extraction
leaves the previous copy untouched and the staging folder is removed
either way. The commit is recorded after the move, as before.

Fixes #187.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ehennestad ehennestad added the fixed Corrects a defect; listed under Fixed label Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Results (R2022a)

858 tests   854 ✅  4m 42s ⏱️
 27 suites    4 💤
  1 files      0 ❌

Results for commit 34fa783.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (R2026a)

858 tests   856 ✅  4m 36s ⏱️
 27 suites    2 💤
  1 files      0 ❌

Results for commit 34fa783.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.14%. Comparing base (c0e3c7e) to head (34fa783).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...+internal/+utility/+git/extractRepositoryArchive.m 84.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #192      +/-   ##
==========================================
- Coverage   80.37%   80.14%   -0.23%     
==========================================
  Files         423      424       +1     
  Lines        4392     4403      +11     
==========================================
- Hits         3530     3529       -1     
- Misses        862      874      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ehennestad
ehennestad merged commit 9030b75 into main Sep 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixed Corrects a defect; listed under Fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

downloadRepository deletes the old copy and ignores whether the new one copied

1 participant