]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/redundancy/video-redundancy.ts
Merge branch 'release/4.0.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / redundancy / video-redundancy.ts
index 44c17f8e529878eea001a1d2879a853f1a5017c6..6f84747da7a69aa05a9741d4942c20bd3fad5307 100644 (file)
@@ -16,15 +16,17 @@ import {
 } from 'sequelize-typescript'
 import { getServerActor } from '@server/models/application/application'
 import { MActor, MVideoForRedundancyAPI, MVideoRedundancy, MVideoRedundancyAP, MVideoRedundancyVideo } from '@server/types/models'
-import { AttributesOnly } from '@shared/core-utils'
-import { VideoRedundanciesTarget } from '@shared/models/redundancy/video-redundancies-filters.model'
 import {
+  CacheFileObject,
   FileRedundancyInformation,
   StreamingPlaylistRedundancyInformation,
-  VideoRedundancy
-} from '@shared/models/redundancy/video-redundancy.model'
-import { CacheFileObject, VideoPrivacy } from '../../../shared'
-import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy'
+  VideoPrivacy,
+  VideoRedundanciesTarget,
+  VideoRedundancy,
+  VideoRedundancyStrategy,
+  VideoRedundancyStrategyWithManual
+} from '@shared/models'
+import { AttributesOnly } from '@shared/typescript-utils'
 import { isTestInstance } from '../../helpers/core-utils'
 import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc'
 import { logger } from '../../helpers/logger'
@@ -160,7 +162,7 @@ export class VideoRedundancyModel extends Model<Partial<AttributesOnly<VideoRedu
       const logIdentifier = `${videoFile.Video.uuid}-${videoFile.resolution}`
       logger.info('Removing duplicated video file %s.', logIdentifier)
 
-      videoFile.Video.removeFileAndTorrent(videoFile, true)
+      videoFile.Video.removeWebTorrentFileAndTorrent(videoFile, true)
         .catch(err => logger.error('Cannot delete %s files.', logIdentifier, { err }))
     }
 
@@ -411,7 +413,7 @@ export class VideoRedundancyModel extends Model<Partial<AttributesOnly<VideoRedu
     return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findOne(query)
   }
 
-  static async listLocalExpired () {
+  static async listLocalExpired (): Promise<MVideoRedundancyVideo[]> {
     const actor = await getServerActor()
 
     const query = {
@@ -701,6 +703,13 @@ export class VideoRedundancyModel extends Model<Partial<AttributesOnly<VideoRedu
     return undefined
   }
 
+  getVideoUUID () {
+    const video = this.getVideo()
+    if (!video) return undefined
+
+    return video.uuid
+  }
+
   isOwned () {
     return !!this.strategy
   }