Create directories before key setup, not on startup

This commit is contained in:
Zlatko Čalušić
2016-12-27 01:35:45 +01:00
parent 75c1eae7f2
commit 061d31829d
2 changed files with 32 additions and 28 deletions

28
main.go
View File

@@ -2,7 +2,6 @@ package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
@@ -10,31 +9,6 @@ import (
"runtime/pprof"
)
func createDirectories(path string) {
log.Println("Creating repository directories")
dirs := []string{
"data",
"index",
"keys",
"locks",
"snapshots",
"tmp",
}
for _, d := range dirs {
if err := os.MkdirAll(filepath.Join(path, d), 0700); err != nil {
log.Fatal(err)
}
}
for i := 0; i < 256; i++ {
if err := os.MkdirAll(filepath.Join(path, "data", fmt.Sprintf("%02x", i)), 0700); err != nil {
log.Fatal(err)
}
}
}
func setupRoutes(path string) *Router {
context := &Context{path}
@@ -72,8 +46,6 @@ func main() {
defer pprof.StopCPUProfile()
}
createDirectories(*path)
router := setupRoutes(*path)
var handler http.Handler