diff --git a/.gitignore b/.gitignore index c6029ad65..e0004004d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ yarn-error.log /ffmpeg-4/ /thumbnails/ /torrents/ +/web-videos/ /videos/ /previews/ /logs/ diff --git a/config/default.yaml b/config/default.yaml index a9e74095e..e590ab300 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -130,7 +130,7 @@ storage: tmp_persistent: 'storage/tmp-persistent/' # As tmp but the directory is not cleaned up between PeerTube restarts bin: 'storage/bin/' avatars: 'storage/avatars/' - videos: 'storage/videos/' + web_videos: 'storage/web-videos/' streaming_playlists: 'storage/streaming-playlists/' redundancy: 'storage/redundancy/' logs: 'storage/logs/' @@ -202,8 +202,8 @@ object_storage: base_url: '' # Example: 'https://mirror.example.com' # Same settings but for web videos - videos: - bucket_name: 'videos' + web_videos: + bucket_name: 'web-videos' prefix: '' base_url: '' diff --git a/config/production.yaml.example b/config/production.yaml.example index 8fccaa517..884300ddb 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -128,7 +128,7 @@ storage: tmp_persistent: '/var/www/peertube/storage/tmp-persistent/' # As tmp but the directory is not cleaned up between PeerTube restarts bin: '/var/www/peertube/storage/bin/' avatars: '/var/www/peertube/storage/avatars/' - videos: '/var/www/peertube/storage/videos/' + web_videos: '/var/www/peertube/storage/web-videos/' streaming_playlists: '/var/www/peertube/storage/streaming-playlists/' redundancy: '/var/www/peertube/storage/redundancy/' logs: '/var/www/peertube/storage/logs/' @@ -200,8 +200,8 @@ object_storage: base_url: '' # Example: 'https://mirror.example.com' # Same settings but for web videos - videos: - bucket_name: 'videos' + web_videos: + bucket_name: 'web-videos' prefix: '' base_url: '' diff --git a/config/test-1.yaml b/config/test-1.yaml index 45ec27e63..b86b48438 100644 --- a/config/test-1.yaml +++ b/config/test-1.yaml @@ -13,7 +13,7 @@ storage: tmp_persistent: 'test1/tmp-persistent/' bin: 'test1/bin/' avatars: 'test1/avatars/' - videos: 'test1/videos/' + web_videos: 'test1/web-videos/' streaming_playlists: 'test1/streaming-playlists/' redundancy: 'test1/redundancy/' logs: 'test1/logs/' diff --git a/config/test-2.yaml b/config/test-2.yaml index 7a06e5650..266e44c17 100644 --- a/config/test-2.yaml +++ b/config/test-2.yaml @@ -13,7 +13,7 @@ storage: tmp_persistent: 'test2/tmp-persistent/' bin: 'test2/bin/' avatars: 'test2/avatars/' - videos: 'test2/videos/' + web_videos: 'test2/web-videos/' streaming_playlists: 'test2/streaming-playlists/' redundancy: 'test2/redundancy/' logs: 'test2/logs/' diff --git a/config/test-3.yaml b/config/test-3.yaml index 4b1563369..b31d37765 100644 --- a/config/test-3.yaml +++ b/config/test-3.yaml @@ -13,7 +13,7 @@ storage: tmp_persistent: 'test3/tmp-persistent/' bin: 'test3/bin/' avatars: 'test3/avatars/' - videos: 'test3/videos/' + web_videos: 'test3/web-videos/' streaming_playlists: 'test3/streaming-playlists/' redundancy: 'test3/redundancy/' logs: 'test3/logs/' diff --git a/config/test-4.yaml b/config/test-4.yaml index 248db4db9..d73b09b56 100644 --- a/config/test-4.yaml +++ b/config/test-4.yaml @@ -13,7 +13,7 @@ storage: tmp_persistent: 'test4/tmp-persistent/' bin: 'test4/bin/' avatars: 'test4/avatars/' - videos: 'test4/videos/' + web_videos: 'test4/web-videos/' streaming_playlists: 'test4/streaming-playlists/' redundancy: 'test4/redundancy/' logs: 'test4/logs/' diff --git a/config/test-5.yaml b/config/test-5.yaml index 04e2cd78d..56cdc5242 100644 --- a/config/test-5.yaml +++ b/config/test-5.yaml @@ -13,7 +13,7 @@ storage: tmp_persistent: 'test5/tmp-persistent/' bin: 'test5/bin/' avatars: 'test5/avatars/' - videos: 'test5/videos/' + web_videos: 'test5/web-videos/' streaming_playlists: 'test5/streaming-playlists/' redundancy: 'test5/redundancy/' logs: 'test5/logs/' diff --git a/config/test-6.yaml b/config/test-6.yaml index 25efe0054..0e212c699 100644 --- a/config/test-6.yaml +++ b/config/test-6.yaml @@ -13,7 +13,7 @@ storage: tmp_persistent: 'test6/tmp-persistent/' bin: 'test6/bin/' avatars: 'test6/avatars/' - videos: 'test6/videos/' + web_videos: 'test6/web-videos/' streaming_playlists: 'test6/streaming-playlists/' redundancy: 'test6/redundancy/' logs: 'test6/logs/' diff --git a/scripts/migrations/peertube-4.2.ts b/scripts/migrations/peertube-4.2.ts index 513c629ef..d8929692b 100644 --- a/scripts/migrations/peertube-4.2.ts +++ b/scripts/migrations/peertube-4.2.ts @@ -78,7 +78,7 @@ async function fillAvatarSizeIfNeeded (accountOrChannel: MAccountDefault | MChan console.log('Filling size of avatars of %s.', accountOrChannel.name) - const { width, height } = await getImageSize(join(CONFIG.STORAGE.ACTOR_IMAGES, avatar.filename)) + const { width, height } = await getImageSize(join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, avatar.filename)) avatar.width = width avatar.height = height @@ -107,8 +107,8 @@ async function generateSmallerAvatar (actor: MActorDefault) { const sourceFilename = bigAvatar.filename const newImageName = buildUUID() + getLowercaseExtension(sourceFilename) - const source = join(CONFIG.STORAGE.ACTOR_IMAGES, sourceFilename) - const destination = join(CONFIG.STORAGE.ACTOR_IMAGES, newImageName) + const source = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, sourceFilename) + const destination = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, newImageName) await processImage({ path: source, destination, newSize: imageSize, keepOriginal: true }) diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index 8d1ded59b..9a73a8600 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts @@ -50,7 +50,7 @@ async function run () { await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true, ThumbnailType.PREVIEW)), await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false, ThumbnailType.MINIATURE)), - await pruneDirectory(CONFIG.STORAGE.ACTOR_IMAGES, doesActorImageExist) + await pruneDirectory(CONFIG.STORAGE.ACTOR_IMAGES_DIR, doesActorImageExist) ) const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR) diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 906a918e3..5ef72058b 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -217,7 +217,7 @@ function checkStorageConfig () { } } - if (CONFIG.STORAGE.VIDEOS_DIR === CONFIG.STORAGE.REDUNDANCY_DIR) { + if (CONFIG.STORAGE.WEB_VIDEOS_DIR === CONFIG.STORAGE.REDUNDANCY_DIR) { logger.warn('Redundancy directory should be different than the videos folder.') } } @@ -290,7 +290,7 @@ function checkLiveConfig () { function checkObjectStorageConfig () { if (CONFIG.OBJECT_STORAGE.ENABLED === true) { - if (!CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME) { + if (!CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME) { throw new Error('videos_bucket should be set when object storage support is enabled.') } @@ -299,10 +299,10 @@ function checkObjectStorageConfig () { } if ( - CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME && - CONFIG.OBJECT_STORAGE.VIDEOS.PREFIX === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.PREFIX + CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME && + CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.PREFIX ) { - if (CONFIG.OBJECT_STORAGE.VIDEOS.PREFIX === '') { + if (CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === '') { throw new Error('Object storage bucket prefixes should be set when the same bucket is used for both types of video.') } diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 3d117d1b9..a872fcba3 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts @@ -18,7 +18,7 @@ function checkMissedConfig () { 'database.hostname', 'database.port', 'database.username', 'database.password', 'database.pool.max', 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', 'email.body.signature', 'email.subject.prefix', - 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', + 'storage.avatars', 'storage.web_videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', 'storage.well_known', 'log.level', 'log.rotation.enabled', 'log.rotation.max_file_size', 'log.rotation.max_files', 'log.anonymize_ip', 'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log', @@ -60,8 +60,8 @@ function checkMissedConfig () { 'object_storage.enabled', 'object_storage.endpoint', 'object_storage.region', 'object_storage.upload_acl.public', 'object_storage.upload_acl.private', 'object_storage.proxy.proxify_private_files', 'object_storage.credentials.access_key_id', 'object_storage.credentials.secret_access_key', 'object_storage.max_upload_part', 'object_storage.streaming_playlists.bucket_name', - 'object_storage.streaming_playlists.prefix', 'object_storage.streaming_playlists.base_url', 'object_storage.videos.bucket_name', - 'object_storage.videos.prefix', 'object_storage.videos.base_url', + 'object_storage.streaming_playlists.prefix', 'object_storage.streaming_playlists.base_url', 'object_storage.web_videos.bucket_name', + 'object_storage.web_videos.prefix', 'object_storage.web_videos.base_url', 'theme.default', 'feeds.videos.count', 'feeds.comments.count', 'geo_ip.enabled', 'geo_ip.country.database_url', diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 5301a1708..37cd852f1 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -106,9 +106,9 @@ const CONFIG = { TMP_DIR: buildPath(config.get('storage.tmp')), TMP_PERSISTENT_DIR: buildPath(config.get('storage.tmp_persistent')), BIN_DIR: buildPath(config.get('storage.bin')), - ACTOR_IMAGES: buildPath(config.get('storage.avatars')), + ACTOR_IMAGES_DIR: buildPath(config.get('storage.avatars')), LOG_DIR: buildPath(config.get('storage.logs')), - VIDEOS_DIR: buildPath(config.get('storage.videos')), + WEB_VIDEOS_DIR: buildPath(config.get('storage.web_videos')), STREAMING_PLAYLISTS_DIR: buildPath(config.get('storage.streaming_playlists')), REDUNDANCY_DIR: buildPath(config.get('storage.redundancy')), THUMBNAILS_DIR: buildPath(config.get('storage.thumbnails')), @@ -140,10 +140,10 @@ const CONFIG = { PROXY: { PROXIFY_PRIVATE_FILES: config.get('object_storage.proxy.proxify_private_files') }, - VIDEOS: { - BUCKET_NAME: config.get('object_storage.videos.bucket_name'), - PREFIX: config.get('object_storage.videos.prefix'), - BASE_URL: config.get('object_storage.videos.base_url') + WEB_VIDEOS: { + BUCKET_NAME: config.get('object_storage.web_videos.bucket_name'), + PREFIX: config.get('object_storage.web_videos.prefix'), + BASE_URL: config.get('object_storage.web_videos.base_url') }, STREAMING_PLAYLISTS: { BUCKET_NAME: config.get('object_storage.streaming_playlists.bucket_name'), diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index d87aa6f54..5116c6396 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -881,8 +881,8 @@ const DIRECTORIES = { }, VIDEOS: { - PUBLIC: CONFIG.STORAGE.VIDEOS_DIR, - PRIVATE: join(CONFIG.STORAGE.VIDEOS_DIR, 'private') + PUBLIC: CONFIG.STORAGE.WEB_VIDEOS_DIR, + PRIVATE: join(CONFIG.STORAGE.WEB_VIDEOS_DIR, 'private') }, HLS_REDUNDANCY: join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') diff --git a/server/lib/files-cache/avatar-permanent-file-cache.ts b/server/lib/files-cache/avatar-permanent-file-cache.ts index 1d77c5bc1..0c508b063 100644 --- a/server/lib/files-cache/avatar-permanent-file-cache.ts +++ b/server/lib/files-cache/avatar-permanent-file-cache.ts @@ -7,7 +7,7 @@ import { AbstractPermanentFileCache } from './shared' export class AvatarPermanentFileCache extends AbstractPermanentFileCache { constructor () { - super(CONFIG.STORAGE.ACTOR_IMAGES) + super(CONFIG.STORAGE.ACTOR_IMAGES_DIR) } protected loadModel (filename: string) { diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts index 872addc58..611e6d0af 100644 --- a/server/lib/local-actor.ts +++ b/server/lib/local-actor.ts @@ -40,7 +40,7 @@ export async function updateLocalActorImageFiles ( const extension = getLowercaseExtension(imagePhysicalFile.filename) const imageName = buildUUID() + extension - const destination = join(CONFIG.STORAGE.ACTOR_IMAGES, imageName) + const destination = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, imageName) await processImageFromWorker({ path: imagePhysicalFile.path, destination, newSize: imageSize, keepOriginal: true }) return { diff --git a/server/lib/object-storage/pre-signed-urls.ts b/server/lib/object-storage/pre-signed-urls.ts index 313654a57..caf149bb8 100644 --- a/server/lib/object-storage/pre-signed-urls.ts +++ b/server/lib/object-storage/pre-signed-urls.ts @@ -15,8 +15,8 @@ export async function generateWebVideoPresignedUrl (options: { const key = generateWebVideoObjectStorageKey(file.filename) const command = new GetObjectCommand({ - Bucket: CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME, - Key: buildKey(key, CONFIG.OBJECT_STORAGE.VIDEOS), + Bucket: CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME, + Key: buildKey(key, CONFIG.OBJECT_STORAGE.WEB_VIDEOS), ResponseContentDisposition: `attachment; filename=${downloadFilename}` }) diff --git a/server/lib/object-storage/urls.ts b/server/lib/object-storage/urls.ts index 84bc1f6c0..d25f84026 100644 --- a/server/lib/object-storage/urls.ts +++ b/server/lib/object-storage/urls.ts @@ -10,7 +10,7 @@ function getInternalUrl (config: BucketInfo, keyWithoutPrefix: string) { // --------------------------------------------------------------------------- function getWebVideoPublicFileUrl (fileUrl: string) { - const baseUrl = CONFIG.OBJECT_STORAGE.VIDEOS.BASE_URL + const baseUrl = CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BASE_URL if (!baseUrl) return fileUrl return replaceByBaseUrl(fileUrl, baseUrl) diff --git a/server/lib/object-storage/videos.ts b/server/lib/object-storage/videos.ts index 300c1f7e1..891e9ff76 100644 --- a/server/lib/object-storage/videos.ts +++ b/server/lib/object-storage/videos.ts @@ -59,7 +59,7 @@ function storeWebVideoFile (video: MVideo, file: MVideoFile) { return storeObject({ inputPath: VideoPathManager.Instance.getFSVideoFileOutputPath(video, file), objectStorageKey: generateWebVideoObjectStorageKey(file.filename), - bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS, + bucketInfo: CONFIG.OBJECT_STORAGE.WEB_VIDEOS, isPrivate: video.hasPrivateStaticPath() }) } @@ -69,7 +69,7 @@ function storeWebVideoFile (video: MVideo, file: MVideoFile) { async function updateWebVideoFileACL (video: MVideo, file: MVideoFile) { await updateObjectACL({ objectStorageKey: generateWebVideoObjectStorageKey(file.filename), - bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS, + bucketInfo: CONFIG.OBJECT_STORAGE.WEB_VIDEOS, isPrivate: video.hasPrivateStaticPath() }) } @@ -103,7 +103,7 @@ function removeHLSFileObjectStorageByFullKey (key: string) { // --------------------------------------------------------------------------- function removeWebVideoObjectStorage (videoFile: MVideoFile) { - return removeObject(generateWebVideoObjectStorageKey(videoFile.filename), CONFIG.OBJECT_STORAGE.VIDEOS) + return removeObject(generateWebVideoObjectStorageKey(videoFile.filename), CONFIG.OBJECT_STORAGE.WEB_VIDEOS) } // --------------------------------------------------------------------------- @@ -130,7 +130,7 @@ async function makeWebVideoFileAvailable (filename: string, destination: string) await makeAvailable({ key, destination, - bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS + bucketInfo: CONFIG.OBJECT_STORAGE.WEB_VIDEOS }) return destination @@ -148,7 +148,7 @@ function getWebVideoFileReadStream (options: { return createObjectReadStream({ key, - bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS, + bucketInfo: CONFIG.OBJECT_STORAGE.WEB_VIDEOS, rangeHeader }) } diff --git a/server/models/actor/actor-image.ts b/server/models/actor/actor-image.ts index 9c34a0101..51085a16d 100644 --- a/server/models/actor/actor-image.ts +++ b/server/models/actor/actor-image.ts @@ -157,11 +157,11 @@ export class ActorImageModel extends Model