summaryrefslogtreecommitdiff
path: root/go/src/cow-dedupe/dedupe.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-06-03 21:00:55 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-06-03 21:00:55 -0400
commit8caefed85ae0253a1ea5b95a5a0ad25146b5d6d7 (patch)
tree96f9859d91469e6ab2781ea0314d4d048f96b1cc /go/src/cow-dedupe/dedupe.go
parent4b93b2a2355d1d74254b8910b7b1b19d5840012a (diff)
cow-dedupe: Use sd_notify as appropriate
Diffstat (limited to 'go/src/cow-dedupe/dedupe.go')
-rw-r--r--go/src/cow-dedupe/dedupe.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/go/src/cow-dedupe/dedupe.go b/go/src/cow-dedupe/dedupe.go
index 84f03f8..4913f3d 100644
--- a/go/src/cow-dedupe/dedupe.go
+++ b/go/src/cow-dedupe/dedupe.go
@@ -28,7 +28,20 @@ func errhandle(err error) {
}
func myStatusLine() statusline.StatusLine {
- return statusline.StopWatch(statusline.RateLimit(statusline.New(os.Stderr), time.Second/2), time.Second)
+ var outs []statusline.StatusLine
+ if C.isatty(2) != 0 {
+ outs = append(outs, statusline.StopWatch(statusline.RateLimit(statusline.New(os.Stderr), time.Second/2), time.Second))
+ }
+ if os.Getenv("NOTIFY_SOCKET") != "" {
+ outs = append(outs, statusline.RateLimit(statusline.DaemonStatus(0), time.Second/2))
+ }
+ if len(outs) == 0 {
+ outs = append(outs, statusline.New(os.Stderr))
+ }
+ if len(outs) == 1 {
+ return outs[0]
+ }
+ return statusline.Tee(outs...)
}
func getFiemaps(paths []string) map[string][]string {