Skip to content

Commit

Permalink
默认只同步一次
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Nov 15, 2024
1 parent 91c1acf commit 2d5e6bd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/sync/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func AddCommands(parent *cobra.Command) {
ch := notify.NewOfficialChanify(chanifyToken)

full := utils.Must1(cmd.Flags().GetBool(`full`))
every := utils.Must1(cmd.Flags().GetDuration(`every`))

cred := Credential{
Author: os.Getenv(`AUTHOR`),
Expand All @@ -38,16 +39,19 @@ func AddCommands(parent *cobra.Command) {
if err := gs.Sync(); err != nil {
ch.Send("同步失败", err.Error(), true)
log.Println(err)
time.Sleep(time.Minute * 15)
continue
} else {
log.Println(`同步完成。`)
ch.Send(`同步成功`, `全部完成,没有错误。`, false)
log.Println(`同步完成。`)
}
if every <= 0 {
break
}
time.Sleep(time.Hour)
time.Sleep(every)
}
},
}
syncCmd.Flags().Bool(`full`, false, `初次备份是否全量扫描更新。`)
syncCmd.Flags().Duration(`every`, 0, `每隔多久同步一次。如果不设置,默认只同步一次。`)
parent.AddCommand(syncCmd)
}

0 comments on commit 2d5e6bd

Please sign in to comment.