-
Notifications
You must be signed in to change notification settings - Fork 1
/
workerClean.go
56 lines (51 loc) · 1.06 KB
/
workerClean.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
52
53
54
55
56
package fsdd
import (
"os"
"syscall"
)
func cleanMetadata(worker int) {
for i := 0; i < worker; i++ {
var utimes [2]syscall.Timespec
utimes[0] = syscall.NsecToTimespec(0)
utimes[1] = utimes[0]
go func() {
for target := range metaChan {
if err := syscall.UtimesNano(target, utimes[:]); err != nil {
errOut("[unable to clean meta] [atime,mtime] [" + target + "] [" + err.Error() + "]")
}
}
ctl.Done()
}()
}
}
func workerRemoveBrokenSymlinks(worker int) {
for i := 0; i < worker; i++ {
go func() {
for s := range rmsymChan {
err := os.Remove(s)
if err != nil {
errOut("[unable to remove invalid symlink] [" + s + "] [" + err.Error() + "]")
failChan <- &file{syminvalid: true}
continue
}
if c.Verbose {
out("[broken symlink removed] [" + s + "]")
}
}
bg.Done()
}()
}
}
func feederReplaceSymlinks() {
for k, v := range sym {
linkChan <- &file{name: v, newlinktarget: k}
ssym++
}
ctl.Done()
}
func feederRemoveBrokenSymlinks() {
for _, s := range syi {
rmsymChan <- s
}
ctl.Done()
}