function insertIntoDB (callback) {
const videoData = {
name: videoInfos.name,
- namePath: videoFile.filename,
+ filename: videoFile.filename,
description: videoInfos.description,
author: res.locals.oauth.token.user.username,
duration: videoFile.duration,
// TODO: add indexes on searchable columns
const VideoSchema = mongoose.Schema({
name: String,
- namePath: String,
+ filename: String,
description: String,
magnetUri: String,
podUrl: String,
const tasks = []
if (video.isOwned()) {
- const videoPath = pathUtils.join(uploadsDir, video.namePath)
+ const videoPath = pathUtils.join(uploadsDir, video.filename)
this.podUrl = http + '://' + host + ':' + port
tasks.push(
// ------------------------------ METHODS ------------------------------
function isOwned () {
- return this.namePath !== null
+ return this.filename !== null
}
function toFormatedJSON () {
name: self.name,
description: self.description,
magnetUri: self.magnetUri,
- namePath: null,
+ filename: null,
author: self.author,
duration: self.duration,
thumbnailBase64: new Buffer(thumbnailData).toString('base64'),
}
function listOwned (callback) {
- // If namePath is not null this is *our* video
- this.find({ namePath: { $ne: null } }, callback)
+ // If filename is not null this is *our* video
+ this.find({ filename: { $ne: null } }, callback)
}
function listRemotes (callback) {
- this.find({ namePath: null }, callback)
+ this.find({ filename: null }, callback)
}
function load (id, callback) {
if (err) return callback(err)
async.each(videos, function (video, callbackEach) {
- const videoPath = pathUtils.join(uploadsDir, video.namePath)
+ const videoPath = pathUtils.join(uploadsDir, video.filename)
seed(videoPath, callbackEach)
}, callback)
})
}
function removeFile (video, callback) {
- fs.unlink(uploadsDir + video.namePath, callback)
+ fs.unlink(uploadsDir + video.filename, callback)
}
// Maybe the torrent is not seeded, but we catch the error to don't stop the removing process