mirror of
https://github.com/restic/rest-server.git
synced 2025-12-07 09:36:13 -08:00
Create directories before key setup, not on startup
This commit is contained in:
28
main.go
28
main.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user