diff options
Diffstat (limited to 'server/lib/thumbnail.ts')
-rw-r--r-- | server/lib/thumbnail.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index 55478299c..5d0c9f742 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import chaiJsonSchema = require('chai-json-schema') | ||
2 | import { copy, move } from 'fs-extra' | ||
1 | import { join } from 'path' | 3 | import { join } from 'path' |
2 | |||
3 | import { ThumbnailType } from '../../shared/models/videos/thumbnail.type' | 4 | import { ThumbnailType } from '../../shared/models/videos/thumbnail.type' |
4 | import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils' | 5 | import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils' |
5 | import { processImage } from '../helpers/image-utils' | 6 | import { processImage } from '../helpers/image-utils' |
@@ -69,7 +70,19 @@ function createVideoMiniatureFromUrl (options: { | |||
69 | ? null | 70 | ? null |
70 | : downloadUrl | 71 | : downloadUrl |
71 | 72 | ||
72 | const thumbnailCreator = () => downloadImage(downloadUrl, basePath, filename, { width, height }) | 73 | // If the thumbnail URL did not change |
74 | const existingUrl = existingThumbnail | ||
75 | ? existingThumbnail.fileUrl | ||
76 | : null | ||
77 | |||
78 | // If the thumbnail URL did not change and has a unique filename (introduced in 3.2), avoid thumbnail processing | ||
79 | const thumbnailUrlChanged = !existingUrl || existingUrl !== downloadUrl || downloadUrl.endsWith(`${video.uuid}.jpg`) | ||
80 | const thumbnailCreator = () => { | ||
81 | if (thumbnailUrlChanged) return downloadImage(downloadUrl, basePath, filename, { width, height }) | ||
82 | |||
83 | return copy(existingThumbnail.getPath(), ThumbnailModel.buildPath(type, filename)) | ||
84 | } | ||
85 | |||
73 | return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) | 86 | return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) |
74 | } | 87 | } |
75 | 88 | ||