multi dataset

This commit is contained in:
2026-02-16 02:37:31 +01:00
parent 1903535dc5
commit 245bd477ee
3 changed files with 174 additions and 9 deletions

View File

@@ -271,6 +271,25 @@ func (s *Server) HandleUploadStream(w http.ResponseWriter, r *http.Request) {
return
}
// Check if dataset is allowed for this client
dataset, err := s.db.GetDatasetByName(clientID, datasetName)
if err != nil || dataset == nil {
log.Printf("Dataset %s not found for client %s", datasetName, clientID)
respondJSON(w, http.StatusForbidden, UploadResponse{
Success: false,
Message: "Dataset not configured for this client",
})
return
}
if !dataset.Enabled {
respondJSON(w, http.StatusForbidden, UploadResponse{
Success: false,
Message: "Dataset is disabled",
})
return
}
ctx := context.Background()
// Upload to S3
@@ -438,13 +457,6 @@ func (s *Server) HandleDownload(w http.ResponseWriter, r *http.Request) {
return
}
// Find snapshot metadata
client, err := s.db.GetClient(clientID)
if err != nil || client == nil {
http.Error(w, "Client not found", http.StatusNotFound)
return
}
targetSnapshot, err := s.db.GetSnapshotByID(clientID, snapshotID)
if err != nil || targetSnapshot == nil {
http.Error(w, "Snapshot not found", http.StatusNotFound)