Store events and config in SQLite
Replace the JSON-file event and config stores with a SQLite database (modernc.org/sqlite, pure-Go so the static build keeps CGO_ENABLED=0). Last-write-wins now rides on the upsert's WHERE clause rather than a Go-side map compare; the sync protocol and HTTP handlers are unchanged. On first start the server auto-imports any legacy events.json/config.json sitting in the data dir, renaming them to *.imported. The -data flag now points at puppy.db; photos still live on the filesystem alongside it.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
pname = "puppy-tracker-server";
|
||||
version = "0.2.0";
|
||||
src = ./server;
|
||||
vendorHash = null; # no external dependencies
|
||||
vendorHash = "sha256-fqXpr9fV1jeT7503uAjb4jjNPlXfESFnXr7/Uc83d4o=";
|
||||
# Pure-Go build for a tiny static binary.
|
||||
env.CGO_ENABLED = "0";
|
||||
ldflags = [ "-s" "-w" ];
|
||||
@@ -76,7 +76,7 @@
|
||||
exec ${server}/bin/puppy-tracker-server \
|
||||
-addr "''${PUPPY_ADDR:-:8080}" \
|
||||
-static ${static}/share/puppy-tracker \
|
||||
-data "$data_dir/events.json"
|
||||
-data "$data_dir/puppy.db"
|
||||
'');
|
||||
meta.description = "Run puppy-tracker locally (data in $XDG_DATA_HOME/puppy-tracker)";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user