summaryrefslogtreecommitdiff
path: root/internal/daemon/upload.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-14 11:34:14 +0300
committerPaul Buetow <paul@buetow.org>2026-04-14 11:34:14 +0300
commit3b54de72892caae23c5bb99eb0bec6aaa7110d00 (patch)
treedc80ea20326ba1660271bd187e38089d7e66f8eb /internal/daemon/upload.go
parent0b090c2698607fcdef039fb703c8c6bac5fceca0 (diff)
refactor: explicit HostAggregate.Stats, uploadKindExtension (ask 64)
- Replace embedded Aggregate with Stats field to avoid promoted MetaScore pitfall - Forward AddRecord and IsActive to Stats - Replace package-level uploadKinds map with uploadKindExtension switch Made-with: Cursor
Diffstat (limited to 'internal/daemon/upload.go')
-rw-r--r--internal/daemon/upload.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/internal/daemon/upload.go b/internal/daemon/upload.go
index 71bffd0..832019e 100644
--- a/internal/daemon/upload.go
+++ b/internal/daemon/upload.go
@@ -14,12 +14,21 @@ import (
const maxUploadBytes = 8 << 20
-var uploadKinds = map[string]string{
- "txt": ".txt",
- "cur.txt": ".cur.txt",
- "records": ".records",
- "os.txt": ".os.txt",
- "cpuinfo.txt": ".cpuinfo.txt",
+func uploadKindExtension(kind string) (ext string, ok bool) {
+ switch kind {
+ case "txt":
+ return ".txt", true
+ case "cur.txt":
+ return ".cur.txt", true
+ case "records":
+ return ".records", true
+ case "os.txt":
+ return ".os.txt", true
+ case "cpuinfo.txt":
+ return ".cpuinfo.txt", true
+ default:
+ return "", false
+ }
}
func uploadHandler(statsDir string, store *authkeys.Store) http.Handler {
@@ -38,7 +47,7 @@ func serveUploadPut(w http.ResponseWriter, r *http.Request, statsDir string, sto
http.Error(w, "bad path", http.StatusBadRequest)
return
}
- ext, ok := uploadKinds[kind]
+ ext, ok := uploadKindExtension(kind)
if !ok {
http.Error(w, "unknown file kind", http.StatusBadRequest)
return