From d13cbcb35664de01e9872317e019a5ba40aacf76 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 21 Apr 2021 15:17:22 +0200 Subject: [PATCH] Check Repo --- checks.go | 11 +++++++++++ commit.go | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/checks.go b/checks.go index a978567..7b5b084 100644 --- a/checks.go +++ b/checks.go @@ -25,3 +25,14 @@ func checkRootFolder(storage string) { if !seen { log.Fatal("Folder ", path, " is required but not present!") } } } + +func repoExistsIn(storage string, repoId string) map[string]bool { + exists_in := map[string]bool{"fs": false, "commits": false, "blocks": false} + + for storageType, _ := range exists_in { + if info, err := os.Stat(filepath.Join(storage, storageType, repoId)); err == nil && info.IsDir() { + exists_in[storageType] = true + } + } + return exists_in +} diff --git a/commit.go b/commit.go index 6eb4754..59f6a3d 100644 --- a/commit.go +++ b/commit.go @@ -22,5 +22,6 @@ type Commit struct { } func cmdCommit(config configCollect) { - log.Println(config) + rexists := repoExistsIn(config.Storage, config.RepoId) + if !rexists["commits"] { log.Fatal("No commits folder found for repo ",config.RepoId) } }