more fuckingfixes
Some checks are pending
CI Pipeline / Run Tests (push) Waiting to run
CI Pipeline / Lint Code (push) Waiting to run
CI Pipeline / Security Scan (push) Waiting to run
CI Pipeline / E2E Tests (push) Blocked by required conditions

This commit is contained in:
Enki 2025-08-28 08:07:13 -07:00
parent 653c291f1d
commit 9eb09c421a
2 changed files with 26 additions and 10 deletions

View File

@ -1504,8 +1504,17 @@ func (g *Gateway) getMetadata(fileHash string) (*FileMetadata, error) {
Chunks: chunks, Chunks: chunks,
} }
// Check in-memory store for additional data (TorrentInfo, etc.)
if memoryMetadata, exists := metadataStore[fileHash]; exists {
// Merge in-memory metadata with database metadata
metadata.TorrentInfo = memoryMetadata.TorrentInfo
metadata.StreamingInfo = memoryMetadata.StreamingInfo
metadata.HLSPlaylist = memoryMetadata.HLSPlaylist
log.Printf("DEBUG: Found TorrentInfo in memory store for %s", fileHash)
}
// Check if file has completed transcoding and add streaming info // Check if file has completed transcoding and add streaming info
if g.transcodingManager != nil { if g.transcodingManager != nil && metadata.StreamingInfo == nil {
status := g.transcodingManager.GetTranscodingStatus(fileHash) status := g.transcodingManager.GetTranscodingStatus(fileHash)
if status == "completed" { if status == "completed" {
// File has been successfully transcoded, mark it as video // File has been successfully transcoded, mark it as video
@ -2451,6 +2460,7 @@ func (g *Gateway) TorrentHandler(w http.ResponseWriter, r *http.Request) {
// Get and validate file hash // Get and validate file hash
vars := mux.Vars(r) vars := mux.Vars(r)
fileHash := vars["hash"] fileHash := vars["hash"]
log.Printf("DEBUG: TorrentHandler called for hash: %s", fileHash)
if err := g.validateFileHash(fileHash); err != nil { if err := g.validateFileHash(fileHash); err != nil {
g.writeErrorResponse(w, ErrInvalidFileHash, err.Error()) g.writeErrorResponse(w, ErrInvalidFileHash, err.Error())
@ -2473,6 +2483,7 @@ func (g *Gateway) TorrentHandler(w http.ResponseWriter, r *http.Request) {
// Get metadata // Get metadata
metadata, err := g.getMetadata(fileHash) metadata, err := g.getMetadata(fileHash)
log.Printf("DEBUG: TorrentHandler metadata lookup for %s: err=%v, metadata=%v", fileHash, err, metadata != nil)
if err != nil { if err != nil {
g.writeErrorResponse(w, ErrFileNotFound, fmt.Sprintf("No file found with hash: %s", fileHash)) g.writeErrorResponse(w, ErrFileNotFound, fmt.Sprintf("No file found with hash: %s", fileHash))
return return
@ -2487,6 +2498,7 @@ func (g *Gateway) TorrentHandler(w http.ResponseWriter, r *http.Request) {
// Check if torrent is available // Check if torrent is available
if metadata.TorrentInfo == nil { if metadata.TorrentInfo == nil {
log.Printf("DEBUG: TorrentHandler - no TorrentInfo for hash %s", fileHash)
g.writeError(w, http.StatusNotFound, "Torrent not available", ErrorTypeNotFound, g.writeError(w, http.StatusNotFound, "Torrent not available", ErrorTypeNotFound,
"No torrent data found for this file") "No torrent data found for this file")
return return

View File

@ -276,16 +276,20 @@ class GatewayUI {
// Handle completion // Handle completion
xhr.addEventListener('load', () => { xhr.addEventListener('load', () => {
if (xhr.status >= 200 && xhr.status < 300) { // Create a Response-like object
const responseObj = {
ok: xhr.status >= 200 && xhr.status < 300,
status: xhr.status,
statusText: xhr.statusText,
json: async () => {
try { try {
const response = JSON.parse(xhr.responseText); return JSON.parse(xhr.responseText);
resolve(response);
} catch (error) { } catch (error) {
reject(new Error('Invalid response format')); throw new Error('Invalid response format');
} }
} else {
reject(new Error(`Upload failed: ${xhr.status} ${xhr.statusText}`));
} }
};
resolve(responseObj);
}); });
// Handle errors // Handle errors