aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-file.ts8
-rw-r--r--server/models/video/video-format-utils.ts2
2 files changed, 9 insertions, 1 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 4df2c20bc..1ad796104 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -457,18 +457,26 @@ export class VideoFileModel extends Model {
457 457
458 // We proxify torrent requests so use a local URL 458 // We proxify torrent requests so use a local URL
459 getTorrentUrl () { 459 getTorrentUrl () {
460 if (!this.torrentFilename) return null
461
460 return WEBSERVER.URL + this.getTorrentStaticPath() 462 return WEBSERVER.URL + this.getTorrentStaticPath()
461 } 463 }
462 464
463 getTorrentStaticPath () { 465 getTorrentStaticPath () {
466 if (!this.torrentFilename) return null
467
464 return join(LAZY_STATIC_PATHS.TORRENTS, this.torrentFilename) 468 return join(LAZY_STATIC_PATHS.TORRENTS, this.torrentFilename)
465 } 469 }
466 470
467 getTorrentDownloadUrl () { 471 getTorrentDownloadUrl () {
472 if (!this.torrentFilename) return null
473
468 return WEBSERVER.URL + join(STATIC_DOWNLOAD_PATHS.TORRENTS, this.torrentFilename) 474 return WEBSERVER.URL + join(STATIC_DOWNLOAD_PATHS.TORRENTS, this.torrentFilename)
469 } 475 }
470 476
471 removeTorrent () { 477 removeTorrent () {
478 if (!this.torrentFilename) return null
479
472 const torrentPath = getTorrentFilePath(this) 480 const torrentPath = getTorrentFilePath(this)
473 return remove(torrentPath) 481 return remove(torrentPath)
474 .catch(err => logger.warn('Cannot delete torrent %s.', torrentPath, { err })) 482 .catch(err => logger.warn('Cannot delete torrent %s.', torrentPath, { err }))
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index a6a1a4f0d..bcba90093 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -205,7 +205,7 @@ function videoFilesModelToFormattedJSON (
205 label: videoFile.resolution + 'p' 205 label: videoFile.resolution + 'p'
206 }, 206 },
207 207
208 magnetUri: includeMagnet 208 magnetUri: includeMagnet && videoFile.torrentFilename
209 ? generateMagnetUri(video, videoFile, trackerUrls) 209 ? generateMagnetUri(video, videoFile, trackerUrls)
210 : undefined, 210 : undefined,
211 211