-
Notifications
You must be signed in to change notification settings - Fork 54
/
walk.go
50 lines (42 loc) 路 970 Bytes
/
walk.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
package push
import (
"github.com/go-errors/errors"
"github.com/itchio/butler/filtering"
"github.com/itchio/wharf/pools"
"github.com/itchio/wharf/tlc"
"github.com/itchio/wharf/wsync"
)
type walkResult struct {
container *tlc.Container
pool wsync.Pool
}
func doWalk(path string, out chan walkResult, errs chan error, fixPerms bool, dereference bool) {
container, err := tlc.WalkAny(path, &tlc.WalkOpts{
Filter: filtering.FilterPaths,
Dereference: dereference,
})
if err != nil {
errs <- errors.Wrap(err, 1)
return
}
pool, err := pools.New(container, path)
if err != nil {
errs <- errors.Wrap(err, 1)
return
}
result := walkResult{
container: container,
pool: pool,
}
if fixPerms {
result.container.FixPermissions(result.pool)
}
if dereference {
for _, s := range result.container.Symlinks {
result.container.Files = append(result.container.Files, &tlc.File{
Path: s.Path,
})
}
}
out <- result
}