Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, macos-26-intel ]
os: [ macos-latest]
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Expand All @@ -116,7 +116,7 @@ jobs:
CGO_ENABLED: 0
strategy:
matrix:
os: [ windows-latest, windows-11-arm ]
os: [ windows-latest]
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![CI](https://github.com/containers/tar-diff/actions/workflows/ci.yml/badge.svg)](https://github.com/containers/tar-diff/actions/workflows/ci.yml)
[![Go Version](https://img.shields.io/badge/go-1.25-blue.svg)](https://golang.org/dl/)
[![Go Version](https://img.shields.io/badge/go-1.26-blue.svg)](https://golang.org/dl/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![codecov](https://codecov.io/gh/containers/tar-diff/graph/badge.svg)](https://codecov.io/gh/containers/tar-diff)

Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/containers/tar-diff

go 1.26

toolchain go1.26.2

require (
github.com/containers/image/v5 v5.36.2
github.com/klauspost/compress v1.18.6
Expand Down
2 changes: 1 addition & 1 deletion pkg/tar-patch/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (f *FilesystemDataSource) SetCurrentFile(file string) error {
err := f.currentFile.Close()
f.currentFile = nil
if err != nil {
return nil
return err
}
}
currentFile, err := os.Open(filepath.Join(f.basePath, file))
Expand Down
31 changes: 31 additions & 0 deletions pkg/tar-patch/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,37 @@ func TestFilesystemDataSource_SetCurrentFile_NotFound(t *testing.T) {
}
}

func TestFilesystemDataSource_SetCurrentFileCloseError(t *testing.T) {
tempDir := t.TempDir()
testFile1 := "test1.txt"
testFile2 := "test2.txt"

filePath1 := filepath.Join(tempDir, testFile1)
filePath2 := filepath.Join(tempDir, testFile2)
if err := os.WriteFile(filePath1, []byte("content1"), 0644); err != nil {
t.Fatalf("failed to create test file: %v", err)
}
if err := os.WriteFile(filePath2, []byte("content2"), 0644); err != nil {
t.Fatalf("failed to create test file: %v", err)
}

ds := NewFilesystemDataSource(tempDir)
if err := ds.SetCurrentFile(testFile1); err != nil {
t.Fatalf("SetCurrentFile failed: %v", err)
}

// Close the file directly to force an error when SetCurrentFile tries to close it
if err := ds.currentFile.Close(); err != nil {
t.Fatalf("failed to pre-close file: %v", err)
}

// Now SetCurrentFile should return an error when trying to close the already-closed file
err := ds.SetCurrentFile(testFile2)
if err == nil {
t.Fatal("expected error from SetCurrentFile when closing already-closed file, got nil")
}
}

func TestFilesystemDataSource_Read(t *testing.T) {
tempDir := t.TempDir()
testFile := "test.txt"
Expand Down
3 changes: 3 additions & 0 deletions tests/test-tar-errors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ expect_fail "tar-patch missing base dir" ./tar-patch "$TEST_DIR/bad-magic.tardif
# tar-patch: valid delta, missing source file
# Force bsdiff-sized payload + -max-bsdiff-size so the delta emits OPEN for data/only.txt;
# otherwise copyRest-only deltas can apply without that file and expect_fail would flake.
# Skips on Windows platform

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be beneficial to add a little more of a "why" to this comment, just a line or two explaining why we're skipping windows for now

if [ "$IS_WINDOWS" != "true" ]; then
mkdir -p "$TEST_DIR/solo/data" "$TEST_DIR/solom/data"
head -c 4096 /dev/zero >"$TEST_DIR/solo/data/only.txt"
cp -a "$TEST_DIR/solo/data/only.txt" "$TEST_DIR/solom/data/only.txt"
Expand All @@ -74,6 +76,7 @@ if [[ -e "$TEST_DIR/solo/data/only.txt" ]]; then
exit 1
fi
expect_fail "tar-patch missing source member" ./tar-patch "$TEST_DIR/solo.tardiff" "$TEST_DIR/solo" "$TEST_DIR/solo-out.tar"
fi

# tar-patch: stdout destination (happy path)
mkdir -p "$TEST_DIR/st/data" "$TEST_DIR/stm/data"
Expand Down
Loading