From 3e6435b4e21c4f8bc5ae65363bb7c313be9713a2 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 20 Jul 2020 10:30:10 -0400 Subject: [PATCH] gitsrht-shell: increase precision of error branch Errors other than no rows in set (e.g. I/O timeout) would be treated as a non-existent repository, which may not in fact be the case. This could lead to auto-creation kicking in and making duplicate repositories, breaking the database invariants. --- gitsrht-shell/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitsrht-shell/main.go b/gitsrht-shell/main.go index ecf6c39..967b9c1 100644 --- a/gitsrht-shell/main.go +++ b/gitsrht-shell/main.go @@ -231,7 +231,7 @@ func main() { if err := row.Scan(&repoId, &repoName, &repoOwnerId, &repoOwnerName, &repoVisibility, &pusherType, &pusherSuspendNotice, - &accessGrant); err != nil { + &accessGrant); err == sql.ErrNoRows { logger.Printf("Lookup failed: %v", err) @@ -312,6 +312,9 @@ func main() { logger.Printf("Autocreated repo %s", path) } + } else if err != nil { + log.Println("A temporary error has occured. Please try again.") + logger.Fatal("Error occured looking up repo: %v", err) } else { log.Printf("\033[93mNOTICE\033[0m: This repository has moved.") log.Printf("Please update your remote to:") -- 2.38.4