diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/storage.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/model/storage.go b/model/storage.go index bfebb6a..fcec125 100644 --- a/model/storage.go +++ b/model/storage.go @@ -6,21 +6,25 @@ import ( "path/filepath" ) -func InitStorage(path string, version string) { - err := os.Mkdir(path, 0750) +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", path) + log.Printf("Created storage folder %s\n", s.Path) if version != "" { - vp := filepath.Join(path, "version.txt") + 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", path) + log.Printf("Storage directory: %s\n", s.Path) } |