diff --git a/config/default.yaml b/config/default.yaml index 6a1e22204a8cc11135095c95d8f4fcf89a59b9dc..909bec1776920895fa8e810f62a6692779c82b00 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -14,7 +14,7 @@ database: # From the project root directory storage: certs: 'certs/' - uploads: 'uploads/' + videos: 'videos/' logs: 'logs/' thumbnails: 'thumbnails/' torrents: 'torrents/' diff --git a/config/test-1.yaml b/config/test-1.yaml index a59566cc4f3362154565ec7817ac611b2835ade4..4be44abc79fa30ae626d380cfa0fad747344f3a0 100644 --- a/config/test-1.yaml +++ b/config/test-1.yaml @@ -11,7 +11,7 @@ database: # From the project root directory storage: certs: 'test1/certs/' - uploads: 'test1/uploads/' + videos: 'test1/videos/' logs: 'test1/logs/' thumbnails: 'test1/thumbnails/' torrents: 'test1/torrents/' diff --git a/config/test-2.yaml b/config/test-2.yaml index 1b937898feac428179aee63d1b0f7e5eb87b8112..c723e6863ee5d7f324d23a789cdc337521837d85 100644 --- a/config/test-2.yaml +++ b/config/test-2.yaml @@ -11,7 +11,7 @@ database: # From the project root directory storage: certs: 'test2/certs/' - uploads: 'test2/uploads/' + videos: 'test2/videos/' logs: 'test2/logs/' thumbnails: 'test2/thumbnails/' torrents: 'test2/torrents/' diff --git a/config/test-3.yaml b/config/test-3.yaml index e522c13e7fcaa25d1c10b89172d0ce5bed350ea5..58417c34b59b0abe5e635c0b0acbf38943021dc1 100644 --- a/config/test-3.yaml +++ b/config/test-3.yaml @@ -11,7 +11,7 @@ database: # From the project root directory storage: certs: 'test3/certs/' - uploads: 'test3/uploads/' + videos: 'test3/videos/' logs: 'test3/logs/' thumbnails: 'test3/thumbnails/' torrents: 'test3/torrents/' diff --git a/config/test-4.yaml b/config/test-4.yaml index e30cd79789490fba263be80f8f70ba9b263a6618..68253cae90395a46d9e40117f4af7c5e3f184cab 100644 --- a/config/test-4.yaml +++ b/config/test-4.yaml @@ -11,7 +11,7 @@ database: # From the project root directory storage: certs: 'test4/certs/' - uploads: 'test4/uploads/' + videos: 'test4/videos/' logs: 'test4/logs/' thumbnails: 'test4/thumbnails/' torrents: 'test4/torrents/' diff --git a/config/test-5.yaml b/config/test-5.yaml index 3a54599f5555761d5a1a506e91a0d09b93be3692..aafd4588969d4dd86bf3d5d2197cce8d63b9d40f 100644 --- a/config/test-5.yaml +++ b/config/test-5.yaml @@ -11,7 +11,7 @@ database: # From the project root directory storage: certs: 'test5/certs/' - uploads: 'test5/uploads/' + videos: 'test5/videos/' logs: 'test5/logs/' thumbnails: 'test5/thumbnails/' torrents: 'test5/torrents/' diff --git a/config/test-6.yaml b/config/test-6.yaml index 31608add2ac32fd42bede89980bb00ee25f55d33..ba83b0bc1db426c1bded8739aebb254f2c610d6b 100644 --- a/config/test-6.yaml +++ b/config/test-6.yaml @@ -11,7 +11,7 @@ database: # From the project root directory storage: certs: 'test6/certs/' - uploads: 'test6/uploads/' + videos: 'test6/videos/' logs: 'test6/logs/' thumbnails: 'test6/thumbnails/' torrents: 'test6/torrents/' diff --git a/server.js b/server.js index e90ed5c253a156cc4ed1f76e41300596cd66d16e..b2d9be9aaff5f87c263ef0bf953a35d509081477 100644 --- a/server.js +++ b/server.js @@ -77,9 +77,9 @@ app.use('/client/*', function (req, res, next) { const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents')) app.use(constants.STATIC_PATHS.TORRENTS, cors(), express.static(torrentsPhysicalPath, { maxAge: 0 })) -// Uploads path for webseeding -const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads')) -app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(uploadsPhysicalPath, { maxAge: 0 })) +// Videos path for webseeding +const videosPhysicalPath = path.join(__dirname, config.get('storage.videos')) +app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(videosPhysicalPath, { maxAge: 0 })) // Thumbnails path for express const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails')) diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index d633af76dd458f11a6c25ff9940678d54c0da9d7..ee47ce7accd4efc418b0d2ddec91f6df1bc1edac 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js @@ -25,7 +25,7 @@ const Video = mongoose.model('Video') // multer configuration const storage = multer.diskStorage({ destination: function (req, file, cb) { - cb(null, constants.CONFIG.STORAGE.UPLOAD_DIR) + cb(null, constants.CONFIG.STORAGE.VIDEOS_DIR) }, filename: function (req, file, cb) { diff --git a/server/initializers/checker.js b/server/initializers/checker.js index 85e9bc98b70061aa968616267bf709bae63eeded..0bc5df92ff9ceae64fd427f10f5d77f6fc73c719 100644 --- a/server/initializers/checker.js +++ b/server/initializers/checker.js @@ -17,7 +17,7 @@ function checkConfig () { const required = [ 'listen.port', 'webserver.https', 'webserver.host', 'webserver.port', 'database.host', 'database.port', 'database.suffix', - 'storage.certs', 'storage.uploads', 'storage.logs', 'storage.thumbnails' + 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails' ] const miss = [] diff --git a/server/initializers/constants.js b/server/initializers/constants.js index fb1cbc5f305929fd26a3732a2b3ab3c3aa2bacb1..f77c4948fe5f39b56f4422767be620a9b8b7094e 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js @@ -38,7 +38,7 @@ const CONFIG = { STORAGE: { CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')), LOG_DIR: path.join(__dirname, '..', '..', config.get('storage.logs')), - UPLOAD_DIR: path.join(__dirname, '..', '..', config.get('storage.uploads')), + VIDEOS_DIR: path.join(__dirname, '..', '..', config.get('storage.videos')), THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails')), TORRENTS_DIR: path.join(__dirname, '..', '..', config.get('storage.torrents')) }, diff --git a/server/models/video.js b/server/models/video.js index 1feefe24fa7667bd49f9df76f048ba9db65cc8d2..05c4f51cb2d7211918e71f5c261b605c2d90b51c 100644 --- a/server/models/video.js +++ b/server/models/video.js @@ -94,7 +94,7 @@ VideoSchema.pre('save', function (next) { const tasks = [] if (video.isOwned()) { - const videoPath = pathUtils.join(constants.CONFIG.STORAGE.UPLOAD_DIR, video.filename) + const videoPath = pathUtils.join(constants.CONFIG.STORAGE.VIDEOS_DIR, video.filename) this.podUrl = constants.CONFIG.WEBSERVER.URL tasks.push( @@ -258,7 +258,7 @@ function removeThumbnail (video, callback) { } function removeFile (video, callback) { - fs.unlink(constants.CONFIG.STORAGE.UPLOAD_DIR + video.filename, callback) + fs.unlink(constants.CONFIG.STORAGE.VIDEOS_DIR + video.filename, callback) } // Maybe the torrent is not seeded, but we catch the error to don't stop the removing process diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js index 623a1a6a3733b16f188213b4055672c08fcf36ce..3125312caf614235910e357df18fd77d464a2414 100644 --- a/server/tests/api/single-pod.js +++ b/server/tests/api/single-pod.js @@ -245,11 +245,18 @@ describe('Test a single pod', function () { videosUtils.removeVideo(server.url, server.accessToken, videoId, function (err) { if (err) throw err - fs.readdir(pathUtils.join(__dirname, '../../../test1/uploads/'), function (err, files) { + fs.readdir(pathUtils.join(__dirname, '../../../test1/videos/'), function (err, files) { if (err) throw err expect(files.length).to.equal(0) - done() + + fs.readdir(pathUtils.join(__dirname, '../../../test1/thumbnails/'), function (err, files) { + if (err) throw err + + expect(files.length).to.equal(0) + + done() + }) }) }) })