Author | Jakob Wakeling <[email protected]> |
Date | 2024-03-15 08:11:22 |
Commit | b6c2a7bb97a1f12d63bf0ec5ecef14f8b4f57d7f |
Parent | 2ac8bbb62765cdf913e0516e728406c8c5e37f01 |
Fix mirror jobs using incorrect RID
Diffstat
M | src/goit/auth_test.go | | | 1 | + |
M | src/goit/config.go | | | 2 | +- |
M | src/goit/goit.go | | | 8 | +++++--- |
M | src/goit/repo.go | | | 12 | ++++++------ |
4 files changed, 13 insertions, 10 deletions
diff --git a/src/goit/auth_test.go b/src/goit/auth_test.go index ddb97bb..3b39c71 100644 --- a/src/goit/auth_test.go +++ b/src/goit/auth_test.go @@ -20,6 +20,7 @@ func TestNewSession(t *testing.T) { var uid int64 = 1 var session = goit.Session{Ip: "127.0.0.1", Expiry: time.Unix(0, 0)} + goit.Conf.IpSessions = true s, err := goit.NewSession(uid, session.Ip, session.Expiry) if err != nil { t.Fatal(err.Error()) diff --git a/src/goit/config.go b/src/goit/config.go index be54bff..df8d4a8 100644 --- a/src/goit/config.go +++ b/src/goit/config.go @@ -52,7 +52,7 @@ func loadConfig() (config, error) { return config{}, err } } else if data != nil { - if json.Unmarshal(data, &conf); err != nil { + if err := json.Unmarshal(data, &conf); err != nil { return config{}, err } } diff --git a/src/goit/goit.go b/src/goit/goit.go index 0a799b2..6011243 100644 --- a/src/goit/goit.go +++ b/src/goit/goit.go @@ -107,11 +107,13 @@ func Goit() error { for _, r := range repos { if r.IsMirror { util.Debugln("Adding mirror cron job for", r.Name) + rid, name := r.Id, r.Name Cron.Add(r.Id, cron.Daily, func() { - if err := Pull(r.Id); err != nil { - log.Println("[cron:mirror]", err.Error()) + if err := Pull(rid); err != nil { + log.Println("[cron:mirror]", rid, name, err.Error()) + } else { + log.Println("[cron:mirror] updated", rid, name) } - log.Println("[cron:mirror] updated", r.Name) }) } } diff --git a/src/goit/repo.go b/src/goit/repo.go index 6a7bf86..8a94d31 100644 --- a/src/goit/repo.go +++ b/src/goit/repo.go @@ -240,13 +240,13 @@ func UpdateRepo(rid int64, repo Repo) error { var r *git.Repository if repo.DefaultBranch != old.DefaultBranch { - if r == nil { - r, err = git.PlainOpen(RepoPath(repo.Name, true)) - if err != nil { - tx.Rollback() - return err - } + // if r == nil { + r, err = git.PlainOpen(RepoPath(repo.Name, true)) + if err != nil { + tx.Rollback() + return err } + // } ref := plumbing.NewSymbolicReference(plumbing.HEAD, plumbing.NewBranchReferenceName(repo.DefaultBranch)) if err := r.Storer.SetReference(ref); err != nil {