From bafaba0bcda0c9fb553b9eebef3764994bb4ff60 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jun 2023 08:53:14 +0200 Subject: Support lazy download of remote video miniatures --- .../video-miniature-permanent-file-cache.ts | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 server/lib/files-cache/video-miniature-permanent-file-cache.ts (limited to 'server/lib/files-cache/video-miniature-permanent-file-cache.ts') diff --git a/server/lib/files-cache/video-miniature-permanent-file-cache.ts b/server/lib/files-cache/video-miniature-permanent-file-cache.ts new file mode 100644 index 000000000..35d9466f7 --- /dev/null +++ b/server/lib/files-cache/video-miniature-permanent-file-cache.ts @@ -0,0 +1,28 @@ +import { CONFIG } from '@server/initializers/config' +import { THUMBNAILS_SIZE } from '@server/initializers/constants' +import { ThumbnailModel } from '@server/models/video/thumbnail' +import { MThumbnail } from '@server/types/models' +import { ThumbnailType } from '@shared/models' +import { AbstractPermanentFileCache } from './shared' + +export class VideoMiniaturePermanentFileCache extends AbstractPermanentFileCache { + + constructor () { + super(CONFIG.STORAGE.THUMBNAILS_DIR) + } + + protected loadModel (filename: string) { + return ThumbnailModel.loadByFilename(filename, ThumbnailType.MINIATURE) + } + + protected getImageSize (image: MThumbnail): { width: number, height: number } { + if (image.width && image.height) { + return { + height: image.height, + width: image.width + } + } + + return THUMBNAILS_SIZE + } +} -- cgit v1.2.3