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 11:10:53 -07:00
parent 74839c86bf
commit c294ce4cff
2 changed files with 14 additions and 3 deletions

View File

@ -1621,10 +1621,11 @@
} }
const baseUrl = window.location.origin; const baseUrl = window.location.origin;
const magnetHash = file.torrent_info?.InfoHash || hash;
const links = { const links = {
direct: `${baseUrl}/api/download/${hash}`, direct: `${baseUrl}/api/download/${hash}`,
torrent: `${baseUrl}/api/torrent/${hash}`, torrent: `${baseUrl}/api/torrent/${hash}`,
magnet: `magnet:?xt=urn:btih:${hash}&dn=${encodeURIComponent(file.name)}`, magnet: `magnet:?xt=urn:btih:${magnetHash}&dn=${encodeURIComponent(file.name)}`,
stream: file.name.match(/\.(mp4|mkv|avi|mov)$/i) ? `${baseUrl}/api/stream/${hash}` : null stream: file.name.match(/\.(mp4|mkv|avi|mov)$/i) ? `${baseUrl}/api/stream/${hash}` : null
}; };

View File

@ -613,10 +613,20 @@ class GatewayUI {
} }
const baseUrl = window.location.origin; const baseUrl = window.location.origin;
// Use torrent info hash for magnet link if available, otherwise use file hash
let magnetHash = hash;
if (fileData && fileData.torrent_info && fileData.torrent_info.InfoHash) {
magnetHash = fileData.torrent_info.InfoHash;
console.log('Using torrent InfoHash for magnet:', magnetHash);
} else {
console.log('No torrent InfoHash found, using file hash:', magnetHash);
}
const links = { const links = {
direct: `${baseUrl}/api/download/${hash}`, direct: `${baseUrl}/api/download/${hash}`,
torrent: `${baseUrl}/api/torrent/${hash}`, torrent: `${baseUrl}/api/torrent/${hash}`,
magnet: `magnet:?xt=urn:btih:${hash}&dn=${encodeURIComponent(name)}` magnet: `magnet:?xt=urn:btih:${magnetHash}&dn=${encodeURIComponent(name)}`
}; };
// Add streaming links if available // Add streaming links if available
@ -628,7 +638,7 @@ class GatewayUI {
this.showShareModal(name, links); this.showShareModal(name, links);
} catch (error) { } catch (error) {
console.error('Failed to get file metadata:', error); console.error('Failed to get file metadata:', error);
// Fallback to basic links // Fallback to basic links (using file hash for magnet since we can't get torrent info)
const baseUrl = window.location.origin; const baseUrl = window.location.origin;
const links = { const links = {
direct: `${baseUrl}/api/download/${hash}`, direct: `${baseUrl}/api/download/${hash}`,