Simulation Upload Update
This commit is contained in:
15
server/db.go
15
server/db.go
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user