Fix queue deserialization for formatOption struct

Handle case where formatOption is loaded from JSON as a map instead
of a struct. This prevents panic when reloading saved queue on startup.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Stu Leak 2025-11-26 18:48:28 -05:00
parent 43ed677838
commit 8a67ce74c8

21
main.go
View File

@ -887,7 +887,26 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
}
// Format-specific settings
selectedFormat := cfg["selectedFormat"].(formatOption)
var selectedFormat formatOption
switch v := cfg["selectedFormat"].(type) {
case formatOption:
selectedFormat = v
case map[string]interface{}:
// Reconstruct from map (happens when loading from JSON)
if label, ok := v["Label"].(string); ok {
selectedFormat.Label = label
}
if ext, ok := v["Ext"].(string); ok {
selectedFormat.Ext = ext
}
if codec, ok := v["VideoCodec"].(string); ok {
selectedFormat.VideoCodec = codec
}
default:
// Fallback to MP4
selectedFormat = formatOptions[0]
}
if strings.EqualFold(selectedFormat.Ext, ".mp4") || strings.EqualFold(selectedFormat.Ext, ".mov") {
args = append(args, "-movflags", "+faststart")
}