diff options
author | Chocobozzz <me@florianbigard.com> | 2023-06-07 08:53:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-06-29 10:19:33 +0200 |
commit | bafaba0bcda0c9fb553b9eebef3764994bb4ff60 (patch) | |
tree | bff9a580cda865cd81c91cd5e1b7b527df45dac1 /server/lib/files-cache | |
parent | f162d32da098aa55f6de2367142faa166edb7c08 (diff) | |
download | PeerTube-bafaba0bcda0c9fb553b9eebef3764994bb4ff60.tar.gz PeerTube-bafaba0bcda0c9fb553b9eebef3764994bb4ff60.tar.zst PeerTube-bafaba0bcda0c9fb553b9eebef3764994bb4ff60.zip |
Support lazy download of remote video miniatures
Diffstat (limited to 'server/lib/files-cache')
-rw-r--r-- | server/lib/files-cache/avatar-permanent-file-cache.ts | 4 | ||||
-rw-r--r-- | server/lib/files-cache/index.ts | 1 | ||||
-rw-r--r-- | server/lib/files-cache/video-miniature-permanent-file-cache.ts | 28 |
3 files changed, 31 insertions, 2 deletions
diff --git a/server/lib/files-cache/avatar-permanent-file-cache.ts b/server/lib/files-cache/avatar-permanent-file-cache.ts index 89228c5a5..1d77c5bc1 100644 --- a/server/lib/files-cache/avatar-permanent-file-cache.ts +++ b/server/lib/files-cache/avatar-permanent-file-cache.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import { CONFIG } from '@server/initializers/config' | ||
1 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' | 2 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' |
2 | import { ActorImageModel } from '@server/models/actor/actor-image' | 3 | import { ActorImageModel } from '@server/models/actor/actor-image' |
3 | import { MActorImage } from '@server/types/models' | 4 | import { MActorImage } from '@server/types/models' |
4 | import { AbstractPermanentFileCache } from './shared' | 5 | import { AbstractPermanentFileCache } from './shared' |
5 | import { CONFIG } from '@server/initializers/config' | ||
6 | 6 | ||
7 | export class AvatarPermanentFileCache extends AbstractPermanentFileCache<ActorImageModel> { | 7 | export class AvatarPermanentFileCache extends AbstractPermanentFileCache<MActorImage> { |
8 | 8 | ||
9 | constructor () { | 9 | constructor () { |
10 | super(CONFIG.STORAGE.ACTOR_IMAGES) | 10 | super(CONFIG.STORAGE.ACTOR_IMAGES) |
diff --git a/server/lib/files-cache/index.ts b/server/lib/files-cache/index.ts index cc11d5385..5630a9b80 100644 --- a/server/lib/files-cache/index.ts +++ b/server/lib/files-cache/index.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | export * from './avatar-permanent-file-cache' | 1 | export * from './avatar-permanent-file-cache' |
2 | export * from './video-miniature-permanent-file-cache' | ||
2 | export * from './video-captions-simple-file-cache' | 3 | export * from './video-captions-simple-file-cache' |
3 | export * from './video-previews-simple-file-cache' | 4 | export * from './video-previews-simple-file-cache' |
4 | export * from './video-storyboards-simple-file-cache' | 5 | export * from './video-storyboards-simple-file-cache' |
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 @@ | |||
1 | import { CONFIG } from '@server/initializers/config' | ||
2 | import { THUMBNAILS_SIZE } from '@server/initializers/constants' | ||
3 | import { ThumbnailModel } from '@server/models/video/thumbnail' | ||
4 | import { MThumbnail } from '@server/types/models' | ||
5 | import { ThumbnailType } from '@shared/models' | ||
6 | import { AbstractPermanentFileCache } from './shared' | ||
7 | |||
8 | export class VideoMiniaturePermanentFileCache extends AbstractPermanentFileCache<MThumbnail> { | ||
9 | |||
10 | constructor () { | ||
11 | super(CONFIG.STORAGE.THUMBNAILS_DIR) | ||
12 | } | ||
13 | |||
14 | protected loadModel (filename: string) { | ||
15 | return ThumbnailModel.loadByFilename(filename, ThumbnailType.MINIATURE) | ||
16 | } | ||
17 | |||
18 | protected getImageSize (image: MThumbnail): { width: number, height: number } { | ||
19 | if (image.width && image.height) { | ||
20 | return { | ||
21 | height: image.height, | ||
22 | width: image.width | ||
23 | } | ||
24 | } | ||
25 | |||
26 | return THUMBNAILS_SIZE | ||
27 | } | ||
28 | } | ||