Compare commits
1 Commits
e16c943296
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6646e02821 |
@@ -331,9 +331,6 @@ func (s *Scanner) ToManifest(ctx context.Context, w io.Writer, progress chan<- S
|
|||||||
// start with a dot (hidden files/directories).
|
// start with a dot (hidden files/directories).
|
||||||
func pathIsHidden(p string) bool {
|
func pathIsHidden(p string) bool {
|
||||||
tp := path.Clean(p)
|
tp := path.Clean(p)
|
||||||
if tp == "." || tp == "/" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(tp, ".") {
|
if strings.HasPrefix(tp, ".") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package mfer
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -96,6 +97,11 @@ func (b *Builder) AddFile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify actual bytes read matches declared size
|
||||||
|
if totalRead != size {
|
||||||
|
return totalRead, fmt.Errorf("size mismatch for %q: declared %d bytes but read %d bytes", path, size, totalRead)
|
||||||
|
}
|
||||||
|
|
||||||
// Encode hash as multihash (SHA2-256)
|
// Encode hash as multihash (SHA2-256)
|
||||||
mh, err := multihash.Encode(h.Sum(nil), multihash.SHA2_256)
|
mh, err := multihash.Encode(h.Sum(nil), multihash.SHA2_256)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -385,9 +385,6 @@ func (s *Scanner) ToManifest(ctx context.Context, w io.Writer, progress chan<- S
|
|||||||
// The path should use forward slashes.
|
// The path should use forward slashes.
|
||||||
func IsHiddenPath(p string) bool {
|
func IsHiddenPath(p string) bool {
|
||||||
tp := path.Clean(p)
|
tp := path.Clean(p)
|
||||||
if tp == "." || tp == "/" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(tp, ".") {
|
if strings.HasPrefix(tp, ".") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,8 +352,6 @@ func TestIsHiddenPath(t *testing.T) {
|
|||||||
{"/absolute/.hidden", true},
|
{"/absolute/.hidden", true},
|
||||||
{"./relative", false}, // path.Clean removes leading ./
|
{"./relative", false}, // path.Clean removes leading ./
|
||||||
{"a/b/c/.d/e", true},
|
{"a/b/c/.d/e", true},
|
||||||
{".", false}, // current directory is not hidden
|
|
||||||
{"/", false}, // root is not hidden
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user