From d9a2a03196275065c28f4a0b7d4d7bc9992d77a1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Feb 2021 10:15:11 +0100 Subject: Don't guess remote tracker URL --- server/lib/thumbnail.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'server/lib/thumbnail.ts') diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index 4bad8d6ca..49317df28 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts @@ -1,5 +1,6 @@ import { copy } from 'fs-extra' import { join } from 'path' +import { logger } from '@server/helpers/logger' import { ThumbnailType } from '../../shared/models/videos/thumbnail.type' import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils' import { processImage } from '../helpers/image-utils' @@ -62,7 +63,7 @@ function createVideoMiniatureFromUrl (options: { size?: ImageSize }) { const { downloadUrl, video, type, size } = options - const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) + const { filename: updatedFilename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) // Only save the file URL if it is a remote video const fileUrl = video.isOwned() @@ -76,10 +77,16 @@ function createVideoMiniatureFromUrl (options: { // If the thumbnail URL did not change and has a unique filename (introduced in 3.2), avoid thumbnail processing const thumbnailUrlChanged = !existingUrl || existingUrl !== downloadUrl || downloadUrl.endsWith(`${video.uuid}.jpg`) + + // Do not change the thumbnail filename if the file did not change + const filename = thumbnailUrlChanged + ? updatedFilename + : existingThumbnail.filename + const thumbnailCreator = () => { if (thumbnailUrlChanged) return downloadImage(downloadUrl, basePath, filename, { width, height }) - return copy(existingThumbnail.getPath(), ThumbnailModel.buildPath(type, filename)) + return Promise.resolve() } return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) @@ -236,7 +243,7 @@ async function createThumbnailFromFunction (parameters: { fileUrl = null } = parameters - const oldFilename = existingThumbnail + const oldFilename = existingThumbnail && existingThumbnail.filename !== filename ? existingThumbnail.filename : undefined @@ -248,7 +255,8 @@ async function createThumbnailFromFunction (parameters: { thumbnail.type = type thumbnail.fileUrl = fileUrl thumbnail.automaticallyGenerated = automaticallyGenerated - thumbnail.previousThumbnailFilename = oldFilename + + if (oldFilename) thumbnail.previousThumbnailFilename = oldFilename await thumbnailCreator() -- cgit v1.2.3