blob: fcec1251262bbc53c9b5c4baa943feaa7ede381a (
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
27
28
29
30
|
package model
import (
"log"
"os"
"path/filepath"
)
type Storage struct {
Path string
}
func (s *Storage) Init(version string) {
err := os.Mkdir(s.Path, 0750)
if err != nil && !os.IsExist(err) {
log.Fatal(err)
}
log.Printf("Created storage folder %s\n", s.Path)
if version != "" {
vp := filepath.Join(s.Path, "version.txt")
err = os.WriteFile(vp, []byte(version+"\n"), 0644)
if err != nil {
log.Fatal(err)
}
}
log.Printf("Storage directory: %s\n", s.Path)
}
|