more fuckingfixes
This commit is contained in:
parent
653c291f1d
commit
9eb09c421a
@ -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
|
||||||
|
@ -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
|
||||||
try {
|
const responseObj = {
|
||||||
const response = JSON.parse(xhr.responseText);
|
ok: xhr.status >= 200 && xhr.status < 300,
|
||||||
resolve(response);
|
status: xhr.status,
|
||||||
} catch (error) {
|
statusText: xhr.statusText,
|
||||||
reject(new Error('Invalid response format'));
|
json: async () => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(xhr.responseText);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('Invalid response format');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
};
|
||||||
reject(new Error(`Upload failed: ${xhr.status} ${xhr.statusText}`));
|
resolve(responseObj);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
|
Loading…
x
Reference in New Issue
Block a user