Skip to content

Commit

Permalink
feat: add corn support
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Sep 16, 2024
1 parent 943e6c4 commit 3facbab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (c *GithubConfig) MergeDefault(defaultConf *DefaultConfig) {
type SyncConfig struct {
DefaultConf *DefaultConfig `json:"default_conf"`
Targets []GithubConfig `json:"targets"`
Cron string `json:"cron"`
}

func ConvertToBackupProviderConfig[T any](raw any) (*T, error) {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/TBXark/github-backup

go 1.22

require github.com/robfig/cron/v3 v3.0.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
15 changes: 14 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"github.com/robfig/cron/v3"
"log"
)

Expand Down Expand Up @@ -141,5 +142,17 @@ func main() {
if err != nil {
log.Fatalf("load config error: %s", err.Error())
}
runBackupTask(conf)

if conf.Cron == "" {
runBackupTask(conf)
} else {
task := cron.New()
_, e := task.AddFunc(conf.Cron, func() {
runBackupTask(conf)
})
if e != nil {
log.Fatalf("add cron task error: %s", e.Error())
}
task.Run()
}
}

0 comments on commit 3facbab

Please sign in to comment.