File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change 88 "os/signal"
99 "path/filepath"
1010 "syscall"
11+ "time"
1112
1213 "github.com/adrg/xdg"
1314 "github.com/cenkalti/log"
@@ -19,8 +20,6 @@ import (
1920// "0.0.0" is the development version.
2021var Version = "0.0.0"
2122
22- // TODO Reconciliation tests
23- // TODO Daemon mode
2423// TODO HTTP API
2524
2625var (
3029 username = flag .String ("username" , "" , "put.io account username" )
3130 password = flag .String ("password" , "" , "put.io account password" )
3231 dryrun = flag .Bool ("dryrun" , false , "do not make changes on filesystems" )
32+ repeat = flag .Duration ("repeat" , 0 , "sync repeatedly, pause given duration between syncs" )
3333)
3434
3535var (
@@ -101,11 +101,25 @@ func main() {
101101 log .Noticef ("Received %s. Stopping sync." , sig )
102102 cancel ()
103103 }()
104- err = syncOnce (ctx )
105- if err != nil {
106- log .Fatal (err )
104+ for {
105+ err = syncOnce (ctx )
106+ if err != nil {
107+ if * repeat == 0 {
108+ log .Fatal (err )
109+ }
110+ log .Error (err )
111+ } else {
112+ log .Infoln ("Sync finished successfully" )
113+ }
114+ if * repeat == 0 {
115+ break
116+ }
117+ select {
118+ case <- time .After (* repeat ):
119+ case <- ctx .Done ():
120+ return
121+ }
107122 }
108- log .Infoln ("Sync finished" )
109123}
110124
111125func syncOnce (ctx context.Context ) error {
You can’t perform that action at this time.
0 commit comments