]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-file.ts
Ensure we don't run transcoding after import file
[github/Chocobozzz/PeerTube.git] / server / models / video / video-file.ts
index 627c957635bb5079ead16cbec64cc12bed6303f3..87311c0edbd671b72b71cf48dcf43c8f64ec7c51 100644 (file)
@@ -1,5 +1,5 @@
 import { remove } from 'fs-extra'
-import * as memoizee from 'memoizee'
+import memoizee from 'memoizee'
 import { join } from 'path'
 import { FindOptions, Op, Transaction } from 'sequelize'
 import {
@@ -25,7 +25,7 @@ import { logger } from '@server/helpers/logger'
 import { extractVideo } from '@server/helpers/video'
 import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage'
 import { getFSTorrentFilePath } from '@server/lib/paths'
-import { MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models'
+import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models'
 import { AttributesOnly } from '@shared/core-utils'
 import { VideoStorage } from '@shared/models'
 import {
@@ -194,6 +194,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
   @Column
   metadataUrl: string
 
+  // Could be null for remote files
   @AllowNull(true)
   @Column
   fileUrl: string
@@ -203,6 +204,7 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
   @Column
   filename: string
 
+  // Could be null for remote files
   @AllowNull(true)
   @Column
   torrentUrl: string
@@ -534,4 +536,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
         (this.videoStreamingPlaylistId !== null && this.videoStreamingPlaylistId === other.videoStreamingPlaylistId)
       )
   }
+
+  withVideoOrPlaylist (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
+    if (isStreamingPlaylist(videoOrPlaylist)) return Object.assign(this, { VideoStreamingPlaylist: videoOrPlaylist })
+
+    return Object.assign(this, { Video: videoOrPlaylist })
+  }
 }