From 6040f87d143a5fa01db79867ece8197c3ce7be47 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Dec 2018 16:02:49 +0100 Subject: Add tmp and redundancy directories --- server/lib/job-queue/handlers/video-import.ts | 9 ++++----- server/lib/job-queue/handlers/video-views.ts | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 4de901c0c..51a0b5faf 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -7,7 +7,7 @@ import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } fro import { extname, join } from 'path' import { VideoFileModel } from '../../../models/video/video-file' import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' -import { doRequestAndSaveToFile, downloadImage } from '../../../helpers/requests' +import { downloadImage } from '../../../helpers/requests' import { VideoState } from '../../../../shared' import { JobQueue } from '../index' import { federateVideoIfNeeded } from '../../activitypub' @@ -109,6 +109,7 @@ async function processFile (downloader: () => Promise, videoImport: Vide let tempVideoPath: string let videoDestFile: string let videoFile: VideoFileModel + try { // Download video from youtubeDL tempVideoPath = await downloader() @@ -144,8 +145,7 @@ async function processFile (downloader: () => Promise, videoImport: Vide // Process thumbnail if (options.downloadThumbnail) { if (options.thumbnailUrl) { - const destThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName()) - await downloadImage(options.thumbnailUrl, destThumbnailPath, THUMBNAILS_SIZE) + await downloadImage(options.thumbnailUrl, CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName(), THUMBNAILS_SIZE) } else { await videoImport.Video.createThumbnail(videoFile) } @@ -156,8 +156,7 @@ async function processFile (downloader: () => Promise, videoImport: Vide // Process preview if (options.downloadPreview) { if (options.thumbnailUrl) { - const destPreviewPath = join(CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName()) - await downloadImage(options.thumbnailUrl, destPreviewPath, PREVIEWS_SIZE) + await downloadImage(options.thumbnailUrl, CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName(), PREVIEWS_SIZE) } else { await videoImport.Video.createPreview(videoFile) } diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.ts index 038ef43e2..fa1fd13b3 100644 --- a/server/lib/job-queue/handlers/video-views.ts +++ b/server/lib/job-queue/handlers/video-views.ts @@ -23,9 +23,7 @@ async function processVideosViews () { for (const videoId of videoIds) { try { const views = await Redis.Instance.getVideoViews(videoId, hour) - if (isNaN(views)) { - logger.error('Cannot process videos views of video %d in hour %d: views number is NaN (%s).', videoId, hour, views) - } else { + if (views) { logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) try { -- cgit v1.2.3