Check Repo

This commit is contained in:
Quentin 2021-04-21 15:17:22 +02:00
parent 5c7c3cf237
commit d13cbcb356
Signed by: quentin
GPG key ID: A98E9B769E4FF428
2 changed files with 13 additions and 1 deletions

View file

@ -25,3 +25,14 @@ func checkRootFolder(storage string) {
if !seen { log.Fatal("Folder ", path, " is required but not present!") } 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
}

View file

@ -22,5 +22,6 @@ type Commit struct {
} }
func cmdCommit(config configCollect) { 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) }
} }