Skip to content

Commit

Permalink
fix: only use basename of filepath in generated checksum file
Browse files Browse the repository at this point in the history
  • Loading branch information
maeb committed Nov 7, 2023
1 parent 3a3cedd commit 7ffed61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/checksum/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/hex"
"io"
"os"
"path/filepath"
)

// MD5Sum returns the md5 checksum of the given file encoded as a hex string.
Expand Down Expand Up @@ -51,7 +52,7 @@ func CreateChecksumFile(file string, checksum string, extension string) (string,
}

checksumFile := file + extension
content := checksum + separator + file + "\n"
content := checksum + separator + filepath.Base(file) + "\n"

// Create checksum file
f, err := os.Create(checksumFile)
Expand Down
3 changes: 2 additions & 1 deletion internal/checksum/checksum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package checksum

import (
"os"
"path/filepath"
"testing"
)

Expand Down Expand Up @@ -78,7 +79,7 @@ func TestCreateChecksumFile(t *testing.T) {
}

got := string(b)
want := wantHash + separator + testFile + "\n"
want := wantHash + separator + filepath.Base(testFile) + "\n"

if got != want {
t.Errorf("expected %s, got %s", want, got)
Expand Down

0 comments on commit 7ffed61

Please sign in to comment.