aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-file.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-25 13:56:07 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-25 15:01:07 +0100
commitd61893f7236abbed30c25b1823e6ecad93a8e8dd (patch)
tree9cf1d47598d9a99f390c6754d289d2573788451d /server/models/video/video-file.ts
parentd7df188f23bb3c4773ac26e6fa8b3d82b1229e6d (diff)
downloadPeerTube-d61893f7236abbed30c25b1823e6ecad93a8e8dd.tar.gz
PeerTube-d61893f7236abbed30c25b1823e6ecad93a8e8dd.tar.zst
PeerTube-d61893f7236abbed30c25b1823e6ecad93a8e8dd.zip
Async torrent creation
Diffstat (limited to 'server/models/video/video-file.ts')
-rw-r--r--server/models/video/video-file.ts8
1 files changed, 8 insertions, 0 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 }))