aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/default.yaml4
-rw-r--r--config/production.yaml.example4
-rw-r--r--config/test-1.yaml2
-rw-r--r--config/test-2.yaml2
-rw-r--r--config/test-3.yaml2
-rw-r--r--config/test-4.yaml2
-rw-r--r--config/test-5.yaml2
-rw-r--r--config/test-6.yaml2
-rw-r--r--config/test.yaml2
-rw-r--r--server/controllers/api/users/me.ts4
-rw-r--r--server/controllers/api/video-channel.ts2
-rw-r--r--server/controllers/api/videos/import.ts6
-rw-r--r--server/controllers/api/videos/index.ts10
-rw-r--r--server/controllers/static.ts9
-rw-r--r--server/helpers/requests.ts9
-rw-r--r--server/helpers/utils.ts6
-rw-r--r--server/helpers/webtorrent.ts6
-rw-r--r--server/helpers/youtube-dl.ts4
-rw-r--r--server/initializers/checker-before-init.ts1
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/lib/activitypub/actor.ts4
-rw-r--r--server/lib/activitypub/videos.ts3
-rw-r--r--server/lib/job-queue/handlers/video-import.ts9
-rw-r--r--server/lib/job-queue/handlers/video-views.ts4
-rw-r--r--server/lib/redis.ts9
-rw-r--r--support/docker/production/config/production.yaml2
26 files changed, 70 insertions, 42 deletions
diff --git a/config/default.yaml b/config/default.yaml
index 257ec7ed1..d95fdc57b 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -45,8 +45,10 @@ smtp:
45 45
46# From the project root directory 46# From the project root directory
47storage: 47storage:
48 tmp: 'storage/tmp/' # Used to download data (imports etc), store uploaded files before processing...
48 avatars: 'storage/avatars/' 49 avatars: 'storage/avatars/'
49 videos: 'storage/videos/' 50 videos: 'storage/videos/'
51 redundancy: 'storage/redundancy/'
50 logs: 'storage/logs/' 52 logs: 'storage/logs/'
51 previews: 'storage/previews/' 53 previews: 'storage/previews/'
52 thumbnails: 'storage/thumbnails/' 54 thumbnails: 'storage/thumbnails/'
@@ -75,7 +77,7 @@ trending:
75redundancy: 77redundancy:
76 videos: 78 videos:
77 check_interval: '1 hour' # How often you want to check new videos to cache 79 check_interval: '1 hour' # How often you want to check new videos to cache
78 strategies: 80 strategies: # Just uncomment strategies you want
79# - 81# -
80# size: '10GB' 82# size: '10GB'
81# # Minimum time the video must remain in the cache. Only accept values > 10 hours (to not overload remote instances) 83# # Minimum time the video must remain in the cache. Only accept values > 10 hours (to not overload remote instances)
diff --git a/config/production.yaml.example b/config/production.yaml.example
index ac15fc736..4c50a550b 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -46,8 +46,10 @@ smtp:
46 46
47# From the project root directory 47# From the project root directory
48storage: 48storage:
49 tmp: '/var/www/peertube/storage/tmp/' # Used to download data (imports etc), store uploaded files before processing...
49 avatars: '/var/www/peertube/storage/avatars/' 50 avatars: '/var/www/peertube/storage/avatars/'
50 videos: '/var/www/peertube/storage/videos/' 51 videos: '/var/www/peertube/storage/videos/'
52 redundancy: '/var/www/peertube/storage/videos/'
51 logs: '/var/www/peertube/storage/logs/' 53 logs: '/var/www/peertube/storage/logs/'
52 previews: '/var/www/peertube/storage/previews/' 54 previews: '/var/www/peertube/storage/previews/'
53 thumbnails: '/var/www/peertube/storage/thumbnails/' 55 thumbnails: '/var/www/peertube/storage/thumbnails/'
@@ -76,7 +78,7 @@ trending:
76redundancy: 78redundancy:
77 videos: 79 videos:
78 check_interval: '1 hour' # How often you want to check new videos to cache 80 check_interval: '1 hour' # How often you want to check new videos to cache
79 strategies: 81 strategies: # Just uncomment strategies you want
80# - 82# -
81# size: '10GB' 83# size: '10GB'
82# # Minimum time the video must remain in the cache. Only accept values > 10 hours (to not overload remote instances) 84# # Minimum time the video must remain in the cache. Only accept values > 10 hours (to not overload remote instances)
diff --git a/config/test-1.yaml b/config/test-1.yaml
index 503bbc661..8f4f66d2a 100644
--- a/config/test-1.yaml
+++ b/config/test-1.yaml
@@ -10,8 +10,10 @@ database:
10 10
11# From the project root directory 11# From the project root directory
12storage: 12storage:
13 tmp: 'test1/tmp/'
13 avatars: 'test1/avatars/' 14 avatars: 'test1/avatars/'
14 videos: 'test1/videos/' 15 videos: 'test1/videos/'
16 redundancy: 'test1/redundancy/'
15 logs: 'test1/logs/' 17 logs: 'test1/logs/'
16 previews: 'test1/previews/' 18 previews: 'test1/previews/'
17 thumbnails: 'test1/thumbnails/' 19 thumbnails: 'test1/thumbnails/'
diff --git a/config/test-2.yaml b/config/test-2.yaml
index 8c77bf581..a80ec6e54 100644
--- a/config/test-2.yaml
+++ b/config/test-2.yaml
@@ -10,8 +10,10 @@ database:
10 10
11# From the project root directory 11# From the project root directory
12storage: 12storage:
13 tmp: 'test2/tmp/'
13 avatars: 'test2/avatars/' 14 avatars: 'test2/avatars/'
14 videos: 'test2/videos/' 15 videos: 'test2/videos/'
16 redundancy: 'test2/redundancy/'
15 logs: 'test2/logs/' 17 logs: 'test2/logs/'
16 previews: 'test2/previews/' 18 previews: 'test2/previews/'
17 thumbnails: 'test2/thumbnails/' 19 thumbnails: 'test2/thumbnails/'
diff --git a/config/test-3.yaml b/config/test-3.yaml
index 82d89567a..934401eb0 100644
--- a/config/test-3.yaml
+++ b/config/test-3.yaml
@@ -10,8 +10,10 @@ database:
10 10
11# From the project root directory 11# From the project root directory
12storage: 12storage:
13 tmp: 'test3/tmp/'
13 avatars: 'test3/avatars/' 14 avatars: 'test3/avatars/'
14 videos: 'test3/videos/' 15 videos: 'test3/videos/'
16 redundancy: 'test3/redundancy/'
15 logs: 'test3/logs/' 17 logs: 'test3/logs/'
16 previews: 'test3/previews/' 18 previews: 'test3/previews/'
17 thumbnails: 'test3/thumbnails/' 19 thumbnails: 'test3/thumbnails/'
diff --git a/config/test-4.yaml b/config/test-4.yaml
index 1aa56d041..ee99b250b 100644
--- a/config/test-4.yaml
+++ b/config/test-4.yaml
@@ -10,8 +10,10 @@ database:
10 10
11# From the project root directory 11# From the project root directory
12storage: 12storage:
13 tmp: 'test4/tmp/'
13 avatars: 'test4/avatars/' 14 avatars: 'test4/avatars/'
14 videos: 'test4/videos/' 15 videos: 'test4/videos/'
16 redundancy: 'test4/redundancy/'
15 logs: 'test4/logs/' 17 logs: 'test4/logs/'
16 previews: 'test4/previews/' 18 previews: 'test4/previews/'
17 thumbnails: 'test4/thumbnails/' 19 thumbnails: 'test4/thumbnails/'
diff --git a/config/test-5.yaml b/config/test-5.yaml
index 5f1c2f583..e2662bdd9 100644
--- a/config/test-5.yaml
+++ b/config/test-5.yaml
@@ -10,8 +10,10 @@ database:
10 10
11# From the project root directory 11# From the project root directory
12storage: 12storage:
13 tmp: 'test5/tmp/'
13 avatars: 'test5/avatars/' 14 avatars: 'test5/avatars/'
14 videos: 'test5/videos/' 15 videos: 'test5/videos/'
16 redundancy: 'test5/redundancy/'
15 logs: 'test5/logs/' 17 logs: 'test5/logs/'
16 previews: 'test5/previews/' 18 previews: 'test5/previews/'
17 thumbnails: 'test5/thumbnails/' 19 thumbnails: 'test5/thumbnails/'
diff --git a/config/test-6.yaml b/config/test-6.yaml
index 719629844..ad39c6a9f 100644
--- a/config/test-6.yaml
+++ b/config/test-6.yaml
@@ -10,8 +10,10 @@ database:
10 10
11# From the project root directory 11# From the project root directory
12storage: 12storage:
13 tmp: 'test6/tmp/'
13 avatars: 'test6/avatars/' 14 avatars: 'test6/avatars/'
14 videos: 'test6/videos/' 15 videos: 'test6/videos/'
16 redundancy: 'test6/redundancy/'
15 logs: 'test6/logs/' 17 logs: 'test6/logs/'
16 previews: 'test6/previews/' 18 previews: 'test6/previews/'
17 thumbnails: 'test6/thumbnails/' 19 thumbnails: 'test6/thumbnails/'
diff --git a/config/test.yaml b/config/test.yaml
index 9c051fabc..51a77e2fd 100644
--- a/config/test.yaml
+++ b/config/test.yaml
@@ -67,4 +67,4 @@ import:
67 enabled: true 67 enabled: true
68 68
69instance: 69instance:
70 default_nsfw_policy: 'display' \ No newline at end of file 70 default_nsfw_policy: 'display'
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index 82299747d..47f2c9ec7 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -42,7 +42,7 @@ import { AccountModel } from '../../../models/account/account'
42 42
43const auditLogger = auditLoggerFactory('users-me') 43const auditLogger = auditLoggerFactory('users-me')
44 44
45const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) 45const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
46 46
47const meRouter = express.Router() 47const meRouter = express.Router()
48 48
@@ -348,7 +348,7 @@ async function updateMe (req: express.Request, res: express.Response, next: expr
348 return res.sendStatus(204) 348 return res.sendStatus(204)
349} 349}
350 350
351async function updateMyAvatar (req: express.Request, res: express.Response, next: express.NextFunction) { 351async function updateMyAvatar (req: express.Request, res: express.Response) {
352 const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ] 352 const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
353 const user: UserModel = res.locals.oauth.token.user 353 const user: UserModel = res.locals.oauth.token.user
354 const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) 354 const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 9bf3c5fd8..63240dfa1 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -32,7 +32,7 @@ import { resetSequelizeInstance } from '../../helpers/database-utils'
32import { UserModel } from '../../models/account/user' 32import { UserModel } from '../../models/account/user'
33 33
34const auditLogger = auditLoggerFactory('channels') 34const auditLogger = auditLoggerFactory('channels')
35const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) 35const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
36 36
37const videoChannelRouter = express.Router() 37const videoChannelRouter = express.Router()
38 38
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 398fd5a7f..f27d648c7 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -37,9 +37,9 @@ const reqVideoFileImport = createReqFiles(
37 [ 'thumbnailfile', 'previewfile', 'torrentfile' ], 37 [ 'thumbnailfile', 'previewfile', 'torrentfile' ],
38 Object.assign({}, TORRENT_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT), 38 Object.assign({}, TORRENT_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT),
39 { 39 {
40 thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR, 40 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
41 previewfile: CONFIG.STORAGE.PREVIEWS_DIR, 41 previewfile: CONFIG.STORAGE.TMP_DIR,
42 torrentfile: CONFIG.STORAGE.TORRENTS_DIR 42 torrentfile: CONFIG.STORAGE.TMP_DIR
43 } 43 }
44) 44)
45 45
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 3d1b2e1a2..4e4697ef4 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -67,17 +67,17 @@ const reqVideoFileAdd = createReqFiles(
67 [ 'videofile', 'thumbnailfile', 'previewfile' ], 67 [ 'videofile', 'thumbnailfile', 'previewfile' ],
68 Object.assign({}, VIDEO_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT), 68 Object.assign({}, VIDEO_MIMETYPE_EXT, IMAGE_MIMETYPE_EXT),
69 { 69 {
70 videofile: CONFIG.STORAGE.VIDEOS_DIR, 70 videofile: CONFIG.STORAGE.TMP_DIR,
71 thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR, 71 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
72 previewfile: CONFIG.STORAGE.PREVIEWS_DIR 72 previewfile: CONFIG.STORAGE.TMP_DIR
73 } 73 }
74) 74)
75const reqVideoFileUpdate = createReqFiles( 75const reqVideoFileUpdate = createReqFiles(
76 [ 'thumbnailfile', 'previewfile' ], 76 [ 'thumbnailfile', 'previewfile' ],
77 IMAGE_MIMETYPE_EXT, 77 IMAGE_MIMETYPE_EXT,
78 { 78 {
79 thumbnailfile: CONFIG.STORAGE.THUMBNAILS_DIR, 79 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
80 previewfile: CONFIG.STORAGE.PREVIEWS_DIR 80 previewfile: CONFIG.STORAGE.TMP_DIR
81 } 81 }
82) 82)
83 83
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 75e30353c..f16a7d72b 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -34,13 +34,18 @@ staticRouter.use(
34) 34)
35 35
36// Videos path for webseeding 36// Videos path for webseeding
37const videosPhysicalPath = CONFIG.STORAGE.VIDEOS_DIR
38staticRouter.use( 37staticRouter.use(
39 STATIC_PATHS.WEBSEED, 38 STATIC_PATHS.WEBSEED,
40 cors(), 39 cors(),
41 express.static(videosPhysicalPath) 40 express.static(CONFIG.STORAGE.VIDEOS_DIR)
42) 41)
43staticRouter.use( 42staticRouter.use(
43 STATIC_PATHS.WEBSEED,
44 cors(),
45 express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }) // 404, because we don't have this video
46)
47
48staticRouter.use(
44 STATIC_DOWNLOAD_PATHS.VIDEOS + ':id-:resolution([0-9]+).:extension', 49 STATIC_DOWNLOAD_PATHS.VIDEOS + ':id-:resolution([0-9]+).:extension',
45 asyncMiddleware(videosGetValidator), 50 asyncMiddleware(videosGetValidator),
46 asyncMiddleware(downloadVideoFile) 51 asyncMiddleware(downloadVideoFile)
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index 5760ad1c1..3fc776f1a 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -1,9 +1,9 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { createWriteStream } from 'fs-extra' 2import { createWriteStream } from 'fs-extra'
3import * as request from 'request' 3import * as request from 'request'
4import { ACTIVITY_PUB } from '../initializers' 4import { ACTIVITY_PUB, CONFIG } from '../initializers'
5import { processImage } from './image-utils' 5import { processImage } from './image-utils'
6import { extname } from 'path' 6import { join } from 'path'
7 7
8function doRequest <T> ( 8function doRequest <T> (
9 requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean } 9 requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }
@@ -29,10 +29,11 @@ function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.U
29 }) 29 })
30} 30}
31 31
32async function downloadImage (url: string, destPath: string, size: { width: number, height: number }) { 32async function downloadImage (url: string, destDir: string, destName: string, size: { width: number, height: number }) {
33 const tmpPath = destPath + '.tmp' + extname(destPath) 33 const tmpPath = join(CONFIG.STORAGE.TMP_DIR, 'pending-' + destName)
34 await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath) 34 await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath)
35 35
36 const destPath = join(destDir, destName)
36 await processImage({ path: tmpPath }, destPath, size) 37 await processImage({ path: tmpPath }, destPath, size)
37} 38}
38 39
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 5c9d6fe2f..9b89e3e61 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -46,11 +46,11 @@ const getServerActor = memoizee(async function () {
46 return actor 46 return actor
47}) 47})
48 48
49function generateVideoTmpPath (target: string | ParseTorrent) { 49function generateVideoImportTmpPath (target: string | ParseTorrent) {
50 const id = typeof target === 'string' ? target : target.infoHash 50 const id = typeof target === 'string' ? target : target.infoHash
51 51
52 const hash = sha256(id) 52 const hash = sha256(id)
53 return join(CONFIG.STORAGE.VIDEOS_DIR, hash + '-import.mp4') 53 return join(CONFIG.STORAGE.TMP_DIR, hash + '-import.mp4')
54} 54}
55 55
56function getSecureTorrentName (originalName: string) { 56function getSecureTorrentName (originalName: string) {
@@ -103,6 +103,6 @@ export {
103 getSecureTorrentName, 103 getSecureTorrentName,
104 getServerActor, 104 getServerActor,
105 getServerCommit, 105 getServerCommit,
106 generateVideoTmpPath, 106 generateVideoImportTmpPath,
107 getUUIDFromFilename 107 getUUIDFromFilename
108} 108}
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts
index ce35b87da..3c9a0b96a 100644
--- a/server/helpers/webtorrent.ts
+++ b/server/helpers/webtorrent.ts
@@ -1,5 +1,5 @@
1import { logger } from './logger' 1import { logger } from './logger'
2import { generateVideoTmpPath } from './utils' 2import { generateVideoImportTmpPath } from './utils'
3import * as WebTorrent from 'webtorrent' 3import * as WebTorrent from 'webtorrent'
4import { createWriteStream, ensureDir, remove } from 'fs-extra' 4import { createWriteStream, ensureDir, remove } from 'fs-extra'
5import { CONFIG } from '../initializers' 5import { CONFIG } from '../initializers'
@@ -9,10 +9,10 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
9 const id = target.magnetUri || target.torrentName 9 const id = target.magnetUri || target.torrentName
10 let timer 10 let timer
11 11
12 const path = generateVideoTmpPath(id) 12 const path = generateVideoImportTmpPath(id)
13 logger.info('Importing torrent video %s', id) 13 logger.info('Importing torrent video %s', id)
14 14
15 const directoryPath = join(CONFIG.STORAGE.VIDEOS_DIR, 'import') 15 const directoryPath = join(CONFIG.STORAGE.TMP_DIR, 'webtorrent')
16 await ensureDir(directoryPath) 16 await ensureDir(directoryPath)
17 17
18 return new Promise<string>((res, rej) => { 18 return new Promise<string>((res, rej) => {
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 2a5663042..b74351b42 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -1,7 +1,7 @@
1import { truncate } from 'lodash' 1import { truncate } from 'lodash'
2import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers' 2import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers'
3import { logger } from './logger' 3import { logger } from './logger'
4import { generateVideoTmpPath } from './utils' 4import { generateVideoImportTmpPath } from './utils'
5import { join } from 'path' 5import { join } from 'path'
6import { root } from './core-utils' 6import { root } from './core-utils'
7import { ensureDir, writeFile, remove } from 'fs-extra' 7import { ensureDir, writeFile, remove } from 'fs-extra'
@@ -40,7 +40,7 @@ function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo>
40} 40}
41 41
42function downloadYoutubeDLVideo (url: string, timeout: number) { 42function downloadYoutubeDLVideo (url: string, timeout: number) {
43 const path = generateVideoTmpPath(url) 43 const path = generateVideoImportTmpPath(url)
44 let timer 44 let timer
45 45
46 logger.info('Importing youtubeDL video %s', url) 46 logger.info('Importing youtubeDL video %s', url)
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 9dfb5d68c..b51c7cfba 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -12,6 +12,7 @@ function checkMissedConfig () {
12 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', 12 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max',
13 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', 13 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address',
14 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 14 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache',
15 'storage.redundancy', 'storage.tmp',
15 'log.level', 16 'log.level',
16 'user.video_quota', 'user.video_quota_daily', 17 'user.video_quota', 'user.video_quota_daily',
17 'cache.previews.size', 'admin.email', 18 'cache.previews.size', 'admin.email',
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 8a8bcd126..876aa1cf5 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -185,9 +185,11 @@ const CONFIG = {
185 FROM_ADDRESS: config.get<string>('smtp.from_address') 185 FROM_ADDRESS: config.get<string>('smtp.from_address')
186 }, 186 },
187 STORAGE: { 187 STORAGE: {
188 TMP_DIR: buildPath(config.get<string>('storage.tmp')),
188 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), 189 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
189 LOG_DIR: buildPath(config.get<string>('storage.logs')), 190 LOG_DIR: buildPath(config.get<string>('storage.logs')),
190 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), 191 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
192 REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')),
191 THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), 193 THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')),
192 PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), 194 PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')),
193 CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), 195 CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')),
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 504263c99..bbe48833d 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -178,9 +178,7 @@ async function fetchAvatarIfExists (actorJSON: ActivityPubActor) {
178 const extension = IMAGE_MIMETYPE_EXT[actorJSON.icon.mediaType] 178 const extension = IMAGE_MIMETYPE_EXT[actorJSON.icon.mediaType]
179 179
180 const avatarName = uuidv4() + extension 180 const avatarName = uuidv4() + extension
181 const destPath = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) 181 await downloadImage(actorJSON.icon.url, CONFIG.STORAGE.AVATARS_DIR, avatarName, AVATARS_SIZE)
182
183 await downloadImage(actorJSON.icon.url, destPath, AVATARS_SIZE)
184 182
185 return avatarName 183 return avatarName
186 } 184 }
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index a5d649391..3d17e6846 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -95,9 +95,8 @@ function fetchRemoteVideoStaticFile (video: VideoModel, path: string, reject: Fu
95 95
96function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject) { 96function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject) {
97 const thumbnailName = video.getThumbnailName() 97 const thumbnailName = video.getThumbnailName()
98 const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, thumbnailName)
99 98
100 return downloadImage(icon.url, thumbnailPath, THUMBNAILS_SIZE) 99 return downloadImage(icon.url, CONFIG.STORAGE.THUMBNAILS_DIR, thumbnailName, THUMBNAILS_SIZE)
101} 100}
102 101
103function getOrCreateVideoChannelFromVideoObject (videoObject: VideoTorrentObject) { 102function getOrCreateVideoChannelFromVideoObject (videoObject: VideoTorrentObject) {
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
7import { extname, join } from 'path' 7import { extname, join } from 'path'
8import { VideoFileModel } from '../../../models/video/video-file' 8import { VideoFileModel } from '../../../models/video/video-file'
9import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' 9import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers'
10import { doRequestAndSaveToFile, downloadImage } from '../../../helpers/requests' 10import { downloadImage } from '../../../helpers/requests'
11import { VideoState } from '../../../../shared' 11import { VideoState } from '../../../../shared'
12import { JobQueue } from '../index' 12import { JobQueue } from '../index'
13import { federateVideoIfNeeded } from '../../activitypub' 13import { federateVideoIfNeeded } from '../../activitypub'
@@ -109,6 +109,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
109 let tempVideoPath: string 109 let tempVideoPath: string
110 let videoDestFile: string 110 let videoDestFile: string
111 let videoFile: VideoFileModel 111 let videoFile: VideoFileModel
112
112 try { 113 try {
113 // Download video from youtubeDL 114 // Download video from youtubeDL
114 tempVideoPath = await downloader() 115 tempVideoPath = await downloader()
@@ -144,8 +145,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
144 // Process thumbnail 145 // Process thumbnail
145 if (options.downloadThumbnail) { 146 if (options.downloadThumbnail) {
146 if (options.thumbnailUrl) { 147 if (options.thumbnailUrl) {
147 const destThumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName()) 148 await downloadImage(options.thumbnailUrl, CONFIG.STORAGE.THUMBNAILS_DIR, videoImport.Video.getThumbnailName(), THUMBNAILS_SIZE)
148 await downloadImage(options.thumbnailUrl, destThumbnailPath, THUMBNAILS_SIZE)
149 } else { 149 } else {
150 await videoImport.Video.createThumbnail(videoFile) 150 await videoImport.Video.createThumbnail(videoFile)
151 } 151 }
@@ -156,8 +156,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide
156 // Process preview 156 // Process preview
157 if (options.downloadPreview) { 157 if (options.downloadPreview) {
158 if (options.thumbnailUrl) { 158 if (options.thumbnailUrl) {
159 const destPreviewPath = join(CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName()) 159 await downloadImage(options.thumbnailUrl, CONFIG.STORAGE.PREVIEWS_DIR, videoImport.Video.getPreviewName(), PREVIEWS_SIZE)
160 await downloadImage(options.thumbnailUrl, destPreviewPath, PREVIEWS_SIZE)
161 } else { 160 } else {
162 await videoImport.Video.createPreview(videoFile) 161 await videoImport.Video.createPreview(videoFile)
163 } 162 }
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 () {
23 for (const videoId of videoIds) { 23 for (const videoId of videoIds) {
24 try { 24 try {
25 const views = await Redis.Instance.getVideoViews(videoId, hour) 25 const views = await Redis.Instance.getVideoViews(videoId, hour)
26 if (isNaN(views)) { 26 if (views) {
27 logger.error('Cannot process videos views of video %d in hour %d: views number is NaN (%s).', videoId, hour, views)
28 } else {
29 logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour) 27 logger.debug('Adding %d views to video %d in hour %d.', views, videoId, hour)
30 28
31 try { 29 try {
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index abd75d512..3e25e6a2c 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -121,7 +121,14 @@ class Redis {
121 const key = this.generateVideoViewKey(videoId, hour) 121 const key = this.generateVideoViewKey(videoId, hour)
122 122
123 const valueString = await this.getValue(key) 123 const valueString = await this.getValue(key)
124 return parseInt(valueString, 10) 124 const valueInt = parseInt(valueString, 10)
125
126 if (isNaN(valueInt)) {
127 logger.error('Cannot get videos views of video %d in hour %d: views number is NaN (%s).', videoId, hour, valueString)
128 return undefined
129 }
130
131 return valueInt
125 } 132 }
126 133
127 async getVideosIdViewed (hour: number) { 134 async getVideosIdViewed (hour: number) {
diff --git a/support/docker/production/config/production.yaml b/support/docker/production/config/production.yaml
index 4970bbcca..846c838e8 100644
--- a/support/docker/production/config/production.yaml
+++ b/support/docker/production/config/production.yaml
@@ -32,8 +32,10 @@ redis:
32 32
33# From the project root directory 33# From the project root directory
34storage: 34storage:
35 tmp: '../data/tmp/'
35 avatars: '../data/avatars/' 36 avatars: '../data/avatars/'
36 videos: '../data/videos/' 37 videos: '../data/videos/'
38 redundancy: '../data/redundancy/'
37 logs: '../data/logs/' 39 logs: '../data/logs/'
38 previews: '../data/previews/' 40 previews: '../data/previews/'
39 thumbnails: '../data/thumbnails/' 41 thumbnails: '../data/thumbnails/'