Skip to content

Commit

Permalink
add fileinfo to skip function
Browse files Browse the repository at this point in the history
  • Loading branch information
tongjingran committed Dec 23, 2020
1 parent 2db1023 commit 939b71c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestOptions_OnSymlink(t *testing.T) {
}

func TestOptions_Skip(t *testing.T) {
opt := Options{Skip: func(src string) (bool, error) {
opt := Options{Skip: func(src string, info os.FileInfo) (bool, error) {
switch {
case strings.HasSuffix(src, "_skip"):
return true, nil
Expand Down
2 changes: 1 addition & 1 deletion copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func switchboard(src, dest string, info os.FileInfo, opt Options) (err error) {
// Because this "copy" could be called recursively,
// "info" MUST be given here, NOT nil.
func copy(src, dest string, info os.FileInfo, opt Options) error {
skip, err := opt.Skip(src)
skip, err := opt.Skip(src, info)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Options struct {
OnDirExists func(src, dest string) DirExistsAction

// Skip can specify which files should be skipped
Skip func(src string) (bool, error)
Skip func(src string, info os.FileInfo) (bool, error)

// AddPermission to every entities,
// NO MORE THAN 0777
Expand Down Expand Up @@ -66,7 +66,7 @@ func getDefaultOptions(src, dest string) Options {
return Shallow // Do shallow copy
},
OnDirExists: nil, // Default behavior is "Merge".
Skip: func(string) (bool, error) {
Skip: func(string, os.FileInfo) (bool, error) {
return false, nil // Don't skip
},
AddPermission: 0, // Add nothing
Expand Down

0 comments on commit 939b71c

Please sign in to comment.