summaryrefslogtreecommitdiff
path: root/model/storage.go
blob: bfebb6a455b8e2ad2a0a40e8a10f630acdb54b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package model

import (
	"log"
	"os"
	"path/filepath"
)

func InitStorage(path string, version string) {
	err := os.Mkdir(path, 0750)
	if err != nil && !os.IsExist(err) {
		log.Fatal(err)
	}

	log.Printf("Created storage folder %s\n", path)

	if version != "" {
		vp := filepath.Join(path, "version.txt")
		err = os.WriteFile(vp, []byte(version+"\n"), 0644)
		if err != nil {
			log.Fatal(err)
		}
	}

	log.Printf("Storage directory: %s\n", path)
}