forked from tonistiigi/fsutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff.go
51 lines (40 loc) · 1.04 KB
/
diff.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package fsutil
import (
"context"
"hash"
"os"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil/types"
)
type walkerFn func(ctx context.Context, pathC chan<- *currentPath) error
func Changes(ctx context.Context, a, b walkerFn, changeFn ChangeFunc) error {
return nil
}
type HandleChangeFn func(ChangeKind, string, os.FileInfo, error) error
type ContentHasher func(*types.Stat) (hash.Hash, error)
func getWalkerFn(root string) walkerFn {
return func(ctx context.Context, pathC chan<- *currentPath) error {
return errors.Wrap(Walk(ctx, root, nil, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
stat, ok := f.Sys().(*types.Stat)
if !ok {
return errors.Errorf("%T invalid file without stat information", f.Sys())
}
p := ¤tPath{
path: path,
stat: stat,
}
select {
case <-ctx.Done():
return ctx.Err()
case pathC <- p:
return nil
}
}), "failed to walk")
}
}
func emptyWalker(ctx context.Context, pathC chan<- *currentPath) error {
return nil
}