Simulation Upload Update

This commit is contained in:
2026-02-21 22:21:05 -05:00
parent 4c24b141fe
commit 913f45b51b
20 changed files with 1479 additions and 492 deletions

View File

@@ -5,6 +5,7 @@ import (
"log"
"os"
"path/filepath"
"strings"
_ "github.com/mattn/go-sqlite3"
)
@@ -17,6 +18,7 @@ type Simulation struct {
Config *string `json:"config"`
SearchTime *float64 `json:"search_time"`
TotalTime *float64 `json:"total_time"`
TotalSizeBytes int64 `json:"total_size_bytes"`
}
var db *sql.DB
@@ -79,9 +81,20 @@ func syncResults() {
// Clear old resources for this simulation
db.Exec("DELETE FROM resources WHERE simulation_id = ?", simID)
// Check for already inserted to avoid dupes if both exist
seen := make(map[string]bool)
for _, sf := range subFiles {
if !sf.IsDir() {
insertResource(simID, sf.Name())
finalName := sf.Name()
if strings.ToLower(filepath.Ext(finalName)) == ".avi" {
finalName = transcodeIfNeeded(filepath.Join(resultsDir, simName), finalName)
}
if !seen[finalName] {
insertResource(simID, finalName)
seen[finalName] = true
}
}
}
}