DHT Nill pointer fix
Some checks failed
CI Pipeline / Run Tests (push) Has been cancelled
CI Pipeline / Lint Code (push) Has been cancelled
CI Pipeline / Security Scan (push) Has been cancelled
CI Pipeline / E2E Tests (push) Has been cancelled

This commit is contained in:
Enki 2025-09-02 22:47:23 -07:00
parent 1472fb7cfd
commit d04e075e51
3 changed files with 12 additions and 0 deletions

View File

@ -1118,10 +1118,14 @@ func (g *Gateway) handleTorrentUpload(w http.ResponseWriter, r *http.Request, fi
} }
// Queue video for transcoding if applicable // Queue video for transcoding if applicable
log.Printf("DEBUG: Transcoding check for %s - transcodingManager: %t, streamingInfo: %t, autoTranscode: %t",
fileName, g.transcodingManager != nil, streamingInfo != nil, g.config.Transcoding.AutoTranscode)
if g.transcodingManager != nil && streamingInfo != nil && g.config.Transcoding.AutoTranscode { if g.transcodingManager != nil && streamingInfo != nil && g.config.Transcoding.AutoTranscode {
// For torrent files, we need to reconstruct the original file for transcoding // For torrent files, we need to reconstruct the original file for transcoding
go func() { go func() {
// Run in background to not block upload response // Run in background to not block upload response
log.Printf("DEBUG: Starting transcoding reconstruction for %s", fileName)
originalPath, err := g.ReconstructTorrentFile(metadata.Hash, fileName) originalPath, err := g.ReconstructTorrentFile(metadata.Hash, fileName)
if err != nil { if err != nil {
log.Printf("Warning: Failed to reconstruct file %s for transcoding: %v", fileName, err) log.Printf("Warning: Failed to reconstruct file %s for transcoding: %v", fileName, err)
@ -1131,6 +1135,8 @@ func (g *Gateway) handleTorrentUpload(w http.ResponseWriter, r *http.Request, fi
log.Printf("Queueing large video file %s for transcoding", fileName) log.Printf("Queueing large video file %s for transcoding", fileName)
g.transcodingManager.QueueVideoForTranscoding(metadata.Hash, fileName, originalPath, metadata.Size) g.transcodingManager.QueueVideoForTranscoding(metadata.Hash, fileName, originalPath, metadata.Size)
}() }()
} else {
log.Printf("DEBUG: Transcoding skipped for %s - missing conditions", fileName)
} }
// Send success response for torrent // Send success response for torrent

View File

@ -2233,6 +2233,12 @@ func (d *DHT) queryNodesParallel(candidates []*Node, targetID NodeID, queryType
wg.Done() wg.Done()
}() }()
// Validate node before proceeding
if node == nil || node.Addr == nil {
log.Printf("DHT query: skipping nil node or address")
return
}
key := fmt.Sprintf("%s:%d", node.Addr.IP, node.Addr.Port) key := fmt.Sprintf("%s:%d", node.Addr.IP, node.Addr.Port)
queriedMutex.Lock() queriedMutex.Lock()
queried[key] = true queried[key] = true

Binary file not shown.