diff options
Diffstat (limited to 'server/models/video/video-file.ts')
-rw-r--r-- | server/models/video/video-file.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 07bc13de1..5e476f3c7 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts | |||
@@ -26,8 +26,8 @@ import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url' | |||
26 | import { | 26 | import { |
27 | getHLSPrivateFileUrl, | 27 | getHLSPrivateFileUrl, |
28 | getHLSPublicFileUrl, | 28 | getHLSPublicFileUrl, |
29 | getWebTorrentPrivateFileUrl, | 29 | getWebVideoPrivateFileUrl, |
30 | getWebTorrentPublicFileUrl | 30 | getWebVideoPublicFileUrl |
31 | } from '@server/lib/object-storage' | 31 | } from '@server/lib/object-storage' |
32 | import { getFSTorrentFilePath } from '@server/lib/paths' | 32 | import { getFSTorrentFilePath } from '@server/lib/paths' |
33 | import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' | 33 | import { isVideoInPrivateDirectory } from '@server/lib/video-privacy' |
@@ -276,15 +276,15 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
276 | 276 | ||
277 | static async doesOwnedTorrentFileExist (filename: string) { | 277 | static async doesOwnedTorrentFileExist (filename: string) { |
278 | const query = 'SELECT 1 FROM "videoFile" ' + | 278 | const query = 'SELECT 1 FROM "videoFile" ' + |
279 | 'LEFT JOIN "video" "webtorrent" ON "webtorrent"."id" = "videoFile"."videoId" AND "webtorrent"."remote" IS FALSE ' + | 279 | 'LEFT JOIN "video" "webvideo" ON "webvideo"."id" = "videoFile"."videoId" AND "webvideo"."remote" IS FALSE ' + |
280 | 'LEFT JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' + | 280 | 'LEFT JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' + |
281 | 'LEFT JOIN "video" "hlsVideo" ON "hlsVideo"."id" = "videoStreamingPlaylist"."videoId" AND "hlsVideo"."remote" IS FALSE ' + | 281 | 'LEFT JOIN "video" "hlsVideo" ON "hlsVideo"."id" = "videoStreamingPlaylist"."videoId" AND "hlsVideo"."remote" IS FALSE ' + |
282 | 'WHERE "torrentFilename" = $filename AND ("hlsVideo"."id" IS NOT NULL OR "webtorrent"."id" IS NOT NULL) LIMIT 1' | 282 | 'WHERE "torrentFilename" = $filename AND ("hlsVideo"."id" IS NOT NULL OR "webvideo"."id" IS NOT NULL) LIMIT 1' |
283 | 283 | ||
284 | return doesExist(this.sequelize, query, { filename }) | 284 | return doesExist(this.sequelize, query, { filename }) |
285 | } | 285 | } |
286 | 286 | ||
287 | static async doesOwnedWebTorrentVideoFileExist (filename: string) { | 287 | static async doesOwnedWebVideoFileExist (filename: string) { |
288 | const query = 'SELECT 1 FROM "videoFile" INNER JOIN "video" ON "video"."id" = "videoFile"."videoId" AND "video"."remote" IS FALSE ' + | 288 | const query = 'SELECT 1 FROM "videoFile" INNER JOIN "video" ON "video"."id" = "videoFile"."videoId" AND "video"."remote" IS FALSE ' + |
289 | `WHERE "filename" = $filename AND "storage" = ${VideoStorage.FILE_SYSTEM} LIMIT 1` | 289 | `WHERE "filename" = $filename AND "storage" = ${VideoStorage.FILE_SYSTEM} LIMIT 1` |
290 | 290 | ||
@@ -378,7 +378,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
378 | } | 378 | } |
379 | 379 | ||
380 | static getStats () { | 380 | static getStats () { |
381 | const webtorrentFilesQuery: FindOptions = { | 381 | const webVideoFilesQuery: FindOptions = { |
382 | include: [ | 382 | include: [ |
383 | { | 383 | { |
384 | attributes: [], | 384 | attributes: [], |
@@ -412,10 +412,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
412 | } | 412 | } |
413 | 413 | ||
414 | return Promise.all([ | 414 | return Promise.all([ |
415 | VideoFileModel.aggregate('size', 'SUM', webtorrentFilesQuery), | 415 | VideoFileModel.aggregate('size', 'SUM', webVideoFilesQuery), |
416 | VideoFileModel.aggregate('size', 'SUM', hlsFilesQuery) | 416 | VideoFileModel.aggregate('size', 'SUM', hlsFilesQuery) |
417 | ]).then(([ webtorrentResult, hlsResult ]) => ({ | 417 | ]).then(([ webVideoResult, hlsResult ]) => ({ |
418 | totalLocalVideoFilesSize: parseAggregateResult(webtorrentResult) + parseAggregateResult(hlsResult) | 418 | totalLocalVideoFilesSize: parseAggregateResult(webVideoResult) + parseAggregateResult(hlsResult) |
419 | })) | 419 | })) |
420 | } | 420 | } |
421 | 421 | ||
@@ -433,7 +433,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
433 | 433 | ||
434 | const element = mode === 'streaming-playlist' | 434 | const element = mode === 'streaming-playlist' |
435 | ? await VideoFileModel.loadHLSFile({ ...baseFind, playlistId: videoFile.videoStreamingPlaylistId }) | 435 | ? await VideoFileModel.loadHLSFile({ ...baseFind, playlistId: videoFile.videoStreamingPlaylistId }) |
436 | : await VideoFileModel.loadWebTorrentFile({ ...baseFind, videoId: videoFile.videoId }) | 436 | : await VideoFileModel.loadWebVideoFile({ ...baseFind, videoId: videoFile.videoId }) |
437 | 437 | ||
438 | if (!element) return videoFile.save({ transaction }) | 438 | if (!element) return videoFile.save({ transaction }) |
439 | 439 | ||
@@ -444,7 +444,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
444 | return element.save({ transaction }) | 444 | return element.save({ transaction }) |
445 | } | 445 | } |
446 | 446 | ||
447 | static async loadWebTorrentFile (options: { | 447 | static async loadWebVideoFile (options: { |
448 | videoId: number | 448 | videoId: number |
449 | fps: number | 449 | fps: number |
450 | resolution: number | 450 | resolution: number |
@@ -523,7 +523,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
523 | return getHLSPrivateFileUrl(video, this.filename) | 523 | return getHLSPrivateFileUrl(video, this.filename) |
524 | } | 524 | } |
525 | 525 | ||
526 | return getWebTorrentPrivateFileUrl(this.filename) | 526 | return getWebVideoPrivateFileUrl(this.filename) |
527 | } | 527 | } |
528 | 528 | ||
529 | private getPublicObjectStorageUrl () { | 529 | private getPublicObjectStorageUrl () { |
@@ -531,7 +531,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
531 | return getHLSPublicFileUrl(this.fileUrl) | 531 | return getHLSPublicFileUrl(this.fileUrl) |
532 | } | 532 | } |
533 | 533 | ||
534 | return getWebTorrentPublicFileUrl(this.fileUrl) | 534 | return getWebVideoPublicFileUrl(this.fileUrl) |
535 | } | 535 | } |
536 | 536 | ||
537 | // --------------------------------------------------------------------------- | 537 | // --------------------------------------------------------------------------- |
@@ -553,10 +553,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel> | |||
553 | getFileStaticPath (video: MVideo) { | 553 | getFileStaticPath (video: MVideo) { |
554 | if (this.isHLS()) return this.getHLSFileStaticPath(video) | 554 | if (this.isHLS()) return this.getHLSFileStaticPath(video) |
555 | 555 | ||
556 | return this.getWebTorrentFileStaticPath(video) | 556 | return this.getWebVideoFileStaticPath(video) |
557 | } | 557 | } |
558 | 558 | ||
559 | private getWebTorrentFileStaticPath (video: MVideo) { | 559 | private getWebVideoFileStaticPath (video: MVideo) { |
560 | if (isVideoInPrivateDirectory(video.privacy)) { | 560 | if (isVideoInPrivateDirectory(video.privacy)) { |
561 | return join(STATIC_PATHS.PRIVATE_WEBSEED, this.filename) | 561 | return join(STATIC_PATHS.PRIVATE_WEBSEED, this.filename) |
562 | } | 562 | } |