summaryrefslogtreecommitdiff
path: root/model/storage.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-05-01 11:21:04 +0200
committerxengineering <me@xengineering.eu>2024-05-01 11:22:13 +0200
commit7cbe33ae59757d67a6b31030aef0769f86acf3c2 (patch)
tree91aa56007773f8c3f95209a466faeaf337f46fd7 /model/storage.go
parentd982951ec15326487eefa80261a0f466d64e2ba0 (diff)
downloadceres-7cbe33ae59757d67a6b31030aef0769f86acf3c2.tar
ceres-7cbe33ae59757d67a6b31030aef0769f86acf3c2.tar.zst
ceres-7cbe33ae59757d67a6b31030aef0769f86acf3c2.zip
model: Add version.txt file to storage folder
This prepares the ability to check for compatibility between a Ceres executable build and an existing storage folder.
Diffstat (limited to 'model/storage.go')
-rw-r--r--model/storage.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/model/storage.go b/model/storage.go
index 39539d4..2ce2fdf 100644
--- a/model/storage.go
+++ b/model/storage.go
@@ -3,11 +3,12 @@ package model
import (
"log"
"os"
+ "path/filepath"
)
var storage string
-func InitStorage() {
+func InitStorage(version string) {
var err error
storage, err = os.MkdirTemp("", "ceres-")
@@ -15,6 +16,14 @@ func InitStorage() {
log.Fatal(err)
}
+ if version != "" {
+ vp := filepath.Join(storage, "version.txt")
+ err = os.WriteFile(vp, []byte(version+"\n"), 0644)
+ if err != nil {
+ log.Fatal(err)
+ }
+ }
+
log.Printf("Storage directory: %s\n", storage)
}