Skip to content

Commit ad26945

Browse files
committed
integrate bindetector into upload via fileutils helpers
1 parent 4c61d74 commit ad26945

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

internal/cli/upload.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func uploadCmd() *cobra.Command {
3333
RunE: uploadFn,
3434
}
3535

36+
// uploadCmd.LocalFlags().Bool("store_type", "", "Storage backend to use")
3637
return uploadCmd
3738
}
3839

internal/fileutils/fileutils.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package fileutils
33
import (
44
"fmt"
55
"io"
6+
"io/fs"
67

8+
"github.com/discentem/cavorite/internal/bindetector"
79
"github.com/spf13/afero"
810
)
911

@@ -23,3 +25,26 @@ func BytesFromAferoFile(f afero.File) ([]byte, error) {
2325
}
2426
return b, nil
2527
}
28+
29+
func GetBinariesWalkPath(fsys afero.Afero, path string) ([]string, error) {
30+
var paths []string
31+
32+
err := fsys.Walk(path, func(p string, info fs.FileInfo, err error) error {
33+
isDir, err := fsys.IsDir(path)
34+
if err != nil {
35+
return err
36+
}
37+
38+
if isDir {
39+
return nil
40+
}
41+
42+
if bindetector.IsBinary(p) {
43+
paths = append(paths, p)
44+
}
45+
46+
return nil
47+
})
48+
49+
return paths, err
50+
}

internal/fileutils/fileutils_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package fileutils
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestGetBinariesWalkPath(t *testing.T) {
10+
// expectedBinariesFromPath := []string{
11+
// "abc.pkg",
12+
// "zxf.pkg",
13+
// }
14+
assert.True(t, true)
15+
}

0 commit comments

Comments
 (0)