MVideoFormattableDetails,
MVideoForUser,
MVideoFullLight,
- MVideoIdThumbnail,
+ MVideoIdThumbnail, MVideoImmutable,
MVideoThumbnail,
MVideoThumbnailBlacklist,
MVideoWithAllFiles,
import { VideoFile } from '@shared/models/videos/video-file.model'
import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
import validator from 'validator'
+import { ModelCache } from '@server/models/model-cache'
export enum ScopeNames {
AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS',
return undefined
}
+ @BeforeDestroy
+ static invalidateCache (instance: VideoModel) {
+ ModelCache.Instance.invalidateCache('video', instance.id)
+ }
+
static listLocal (): Bluebird<MVideoWithAllFiles[]> {
const query = {
where: {
]).findOne(options)
}
+ static loadImmutableAttributes (id: number | string, t?: Transaction): Bluebird<MVideoImmutable> {
+ const fun = () => {
+ const where = buildWhereIdOrUUID(id)
+ const options = {
+ attributes: [
+ 'id', 'url', 'uuid'
+ ],
+ where,
+ transaction: t
+ }
+
+ return VideoModel.unscoped().findOne(options)
+ }
+
+ return ModelCache.Instance.doCache({
+ cacheType: 'video-immutable',
+ key: '' + id,
+ deleteKey: 'video',
+ fun
+ })
+ }
+
static loadWithRights (id: number | string, t?: Transaction): Bluebird<MVideoWithRights> {
const where = buildWhereIdOrUUID(id)
const options = {