Server: Uploads -> Videos
This commit is contained in:
parent
80a6c9e76f
commit
b3d9251015
|
@ -14,7 +14,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'certs/'
|
certs: 'certs/'
|
||||||
uploads: 'uploads/'
|
videos: 'videos/'
|
||||||
logs: 'logs/'
|
logs: 'logs/'
|
||||||
thumbnails: 'thumbnails/'
|
thumbnails: 'thumbnails/'
|
||||||
torrents: 'torrents/'
|
torrents: 'torrents/'
|
||||||
|
|
|
@ -11,7 +11,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'test1/certs/'
|
certs: 'test1/certs/'
|
||||||
uploads: 'test1/uploads/'
|
videos: 'test1/videos/'
|
||||||
logs: 'test1/logs/'
|
logs: 'test1/logs/'
|
||||||
thumbnails: 'test1/thumbnails/'
|
thumbnails: 'test1/thumbnails/'
|
||||||
torrents: 'test1/torrents/'
|
torrents: 'test1/torrents/'
|
||||||
|
|
|
@ -11,7 +11,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'test2/certs/'
|
certs: 'test2/certs/'
|
||||||
uploads: 'test2/uploads/'
|
videos: 'test2/videos/'
|
||||||
logs: 'test2/logs/'
|
logs: 'test2/logs/'
|
||||||
thumbnails: 'test2/thumbnails/'
|
thumbnails: 'test2/thumbnails/'
|
||||||
torrents: 'test2/torrents/'
|
torrents: 'test2/torrents/'
|
||||||
|
|
|
@ -11,7 +11,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'test3/certs/'
|
certs: 'test3/certs/'
|
||||||
uploads: 'test3/uploads/'
|
videos: 'test3/videos/'
|
||||||
logs: 'test3/logs/'
|
logs: 'test3/logs/'
|
||||||
thumbnails: 'test3/thumbnails/'
|
thumbnails: 'test3/thumbnails/'
|
||||||
torrents: 'test3/torrents/'
|
torrents: 'test3/torrents/'
|
||||||
|
|
|
@ -11,7 +11,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'test4/certs/'
|
certs: 'test4/certs/'
|
||||||
uploads: 'test4/uploads/'
|
videos: 'test4/videos/'
|
||||||
logs: 'test4/logs/'
|
logs: 'test4/logs/'
|
||||||
thumbnails: 'test4/thumbnails/'
|
thumbnails: 'test4/thumbnails/'
|
||||||
torrents: 'test4/torrents/'
|
torrents: 'test4/torrents/'
|
||||||
|
|
|
@ -11,7 +11,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'test5/certs/'
|
certs: 'test5/certs/'
|
||||||
uploads: 'test5/uploads/'
|
videos: 'test5/videos/'
|
||||||
logs: 'test5/logs/'
|
logs: 'test5/logs/'
|
||||||
thumbnails: 'test5/thumbnails/'
|
thumbnails: 'test5/thumbnails/'
|
||||||
torrents: 'test5/torrents/'
|
torrents: 'test5/torrents/'
|
||||||
|
|
|
@ -11,7 +11,7 @@ database:
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
certs: 'test6/certs/'
|
certs: 'test6/certs/'
|
||||||
uploads: 'test6/uploads/'
|
videos: 'test6/videos/'
|
||||||
logs: 'test6/logs/'
|
logs: 'test6/logs/'
|
||||||
thumbnails: 'test6/thumbnails/'
|
thumbnails: 'test6/thumbnails/'
|
||||||
torrents: 'test6/torrents/'
|
torrents: 'test6/torrents/'
|
||||||
|
|
|
@ -77,9 +77,9 @@ app.use('/client/*', function (req, res, next) {
|
||||||
const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents'))
|
const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents'))
|
||||||
app.use(constants.STATIC_PATHS.TORRENTS, cors(), express.static(torrentsPhysicalPath, { maxAge: 0 }))
|
app.use(constants.STATIC_PATHS.TORRENTS, cors(), express.static(torrentsPhysicalPath, { maxAge: 0 }))
|
||||||
|
|
||||||
// Uploads path for webseeding
|
// Videos path for webseeding
|
||||||
const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads'))
|
const videosPhysicalPath = path.join(__dirname, config.get('storage.videos'))
|
||||||
app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(uploadsPhysicalPath, { maxAge: 0 }))
|
app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(videosPhysicalPath, { maxAge: 0 }))
|
||||||
|
|
||||||
// Thumbnails path for express
|
// Thumbnails path for express
|
||||||
const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails'))
|
const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails'))
|
||||||
|
|
|
@ -25,7 +25,7 @@ const Video = mongoose.model('Video')
|
||||||
// multer configuration
|
// multer configuration
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: function (req, file, cb) {
|
destination: function (req, file, cb) {
|
||||||
cb(null, constants.CONFIG.STORAGE.UPLOAD_DIR)
|
cb(null, constants.CONFIG.STORAGE.VIDEOS_DIR)
|
||||||
},
|
},
|
||||||
|
|
||||||
filename: function (req, file, cb) {
|
filename: function (req, file, cb) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ function checkConfig () {
|
||||||
const required = [ 'listen.port',
|
const required = [ 'listen.port',
|
||||||
'webserver.https', 'webserver.host', 'webserver.port',
|
'webserver.https', 'webserver.host', 'webserver.port',
|
||||||
'database.host', 'database.port', 'database.suffix',
|
'database.host', 'database.port', 'database.suffix',
|
||||||
'storage.certs', 'storage.uploads', 'storage.logs', 'storage.thumbnails'
|
'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails'
|
||||||
]
|
]
|
||||||
const miss = []
|
const miss = []
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ const CONFIG = {
|
||||||
STORAGE: {
|
STORAGE: {
|
||||||
CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')),
|
CERT_DIR: path.join(__dirname, '..', '..', config.get('storage.certs')),
|
||||||
LOG_DIR: path.join(__dirname, '..', '..', config.get('storage.logs')),
|
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')),
|
THUMBNAILS_DIR: path.join(__dirname, '..', '..', config.get('storage.thumbnails')),
|
||||||
TORRENTS_DIR: path.join(__dirname, '..', '..', config.get('storage.torrents'))
|
TORRENTS_DIR: path.join(__dirname, '..', '..', config.get('storage.torrents'))
|
||||||
},
|
},
|
||||||
|
|
|
@ -94,7 +94,7 @@ VideoSchema.pre('save', function (next) {
|
||||||
const tasks = []
|
const tasks = []
|
||||||
|
|
||||||
if (video.isOwned()) {
|
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
|
this.podUrl = constants.CONFIG.WEBSERVER.URL
|
||||||
|
|
||||||
tasks.push(
|
tasks.push(
|
||||||
|
@ -258,7 +258,7 @@ function removeThumbnail (video, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeFile (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
|
// Maybe the torrent is not seeded, but we catch the error to don't stop the removing process
|
||||||
|
|
|
@ -245,11 +245,18 @@ describe('Test a single pod', function () {
|
||||||
videosUtils.removeVideo(server.url, server.accessToken, videoId, function (err) {
|
videosUtils.removeVideo(server.url, server.accessToken, videoId, function (err) {
|
||||||
if (err) throw 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
|
if (err) throw err
|
||||||
|
|
||||||
expect(files.length).to.equal(0)
|
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()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue