diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-06-28 20:19:41 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-06-28 20:19:41 +0200 |
commit | 5189d08aac7b022a56cf765277558782d151d92f (patch) | |
tree | 8d0dff23fb3448b1d0a05baaa1c0f9cf00646deb /server | |
parent | 907e9510c28b4b2816cba0c070e3feaa16b10ac3 (diff) | |
download | PeerTube-5189d08aac7b022a56cf765277558782d151d92f.tar.gz PeerTube-5189d08aac7b022a56cf765277558782d151d92f.tar.zst PeerTube-5189d08aac7b022a56cf765277558782d151d92f.zip |
Video model: namePath -> filename
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/v1/videos.js | 2 | ||||
-rw-r--r-- | server/models/video.js | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index 83734b35e..d06ec8d08 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -90,7 +90,7 @@ function addVideo (req, res, next) { | |||
90 | function insertIntoDB (callback) { | 90 | function insertIntoDB (callback) { |
91 | const videoData = { | 91 | const videoData = { |
92 | name: videoInfos.name, | 92 | name: videoInfos.name, |
93 | namePath: videoFile.filename, | 93 | filename: videoFile.filename, |
94 | description: videoInfos.description, | 94 | description: videoInfos.description, |
95 | author: res.locals.oauth.token.user.username, | 95 | author: res.locals.oauth.token.user.username, |
96 | duration: videoFile.duration, | 96 | duration: videoFile.duration, |
diff --git a/server/models/video.js b/server/models/video.js index b111e29aa..a8a70ba89 100644 --- a/server/models/video.js +++ b/server/models/video.js | |||
@@ -24,7 +24,7 @@ const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage. | |||
24 | // TODO: add indexes on searchable columns | 24 | // TODO: add indexes on searchable columns |
25 | const VideoSchema = mongoose.Schema({ | 25 | const VideoSchema = mongoose.Schema({ |
26 | name: String, | 26 | name: String, |
27 | namePath: String, | 27 | filename: String, |
28 | description: String, | 28 | description: String, |
29 | magnetUri: String, | 29 | magnetUri: String, |
30 | podUrl: String, | 30 | podUrl: String, |
@@ -98,7 +98,7 @@ VideoSchema.pre('save', function (next) { | |||
98 | const tasks = [] | 98 | const tasks = [] |
99 | 99 | ||
100 | if (video.isOwned()) { | 100 | if (video.isOwned()) { |
101 | const videoPath = pathUtils.join(uploadsDir, video.namePath) | 101 | const videoPath = pathUtils.join(uploadsDir, video.filename) |
102 | this.podUrl = http + '://' + host + ':' + port | 102 | this.podUrl = http + '://' + host + ':' + port |
103 | 103 | ||
104 | tasks.push( | 104 | tasks.push( |
@@ -134,7 +134,7 @@ mongoose.model('Video', VideoSchema) | |||
134 | // ------------------------------ METHODS ------------------------------ | 134 | // ------------------------------ METHODS ------------------------------ |
135 | 135 | ||
136 | function isOwned () { | 136 | function isOwned () { |
137 | return this.namePath !== null | 137 | return this.filename !== null |
138 | } | 138 | } |
139 | 139 | ||
140 | function toFormatedJSON () { | 140 | function toFormatedJSON () { |
@@ -169,7 +169,7 @@ function toRemoteJSON (callback) { | |||
169 | name: self.name, | 169 | name: self.name, |
170 | description: self.description, | 170 | description: self.description, |
171 | magnetUri: self.magnetUri, | 171 | magnetUri: self.magnetUri, |
172 | namePath: null, | 172 | filename: null, |
173 | author: self.author, | 173 | author: self.author, |
174 | duration: self.duration, | 174 | duration: self.duration, |
175 | thumbnailBase64: new Buffer(thumbnailData).toString('base64'), | 175 | thumbnailBase64: new Buffer(thumbnailData).toString('base64'), |
@@ -206,12 +206,12 @@ function listByUrls (fromUrls, callback) { | |||
206 | } | 206 | } |
207 | 207 | ||
208 | function listOwned (callback) { | 208 | function listOwned (callback) { |
209 | // If namePath is not null this is *our* video | 209 | // If filename is not null this is *our* video |
210 | this.find({ namePath: { $ne: null } }, callback) | 210 | this.find({ filename: { $ne: null } }, callback) |
211 | } | 211 | } |
212 | 212 | ||
213 | function listRemotes (callback) { | 213 | function listRemotes (callback) { |
214 | this.find({ namePath: null }, callback) | 214 | this.find({ filename: null }, callback) |
215 | } | 215 | } |
216 | 216 | ||
217 | function load (id, callback) { | 217 | function load (id, callback) { |
@@ -235,7 +235,7 @@ function seedAllExisting (callback) { | |||
235 | if (err) return callback(err) | 235 | if (err) return callback(err) |
236 | 236 | ||
237 | async.each(videos, function (video, callbackEach) { | 237 | async.each(videos, function (video, callbackEach) { |
238 | const videoPath = pathUtils.join(uploadsDir, video.namePath) | 238 | const videoPath = pathUtils.join(uploadsDir, video.filename) |
239 | seed(videoPath, callbackEach) | 239 | seed(videoPath, callbackEach) |
240 | }, callback) | 240 | }, callback) |
241 | }) | 241 | }) |
@@ -267,7 +267,7 @@ function removeThumbnail (video, callback) { | |||
267 | } | 267 | } |
268 | 268 | ||
269 | function removeFile (video, callback) { | 269 | function removeFile (video, callback) { |
270 | fs.unlink(uploadsDir + video.namePath, callback) | 270 | fs.unlink(uploadsDir + video.filename, callback) |
271 | } | 271 | } |
272 | 272 | ||
273 | // Maybe the torrent is not seeded, but we catch the error to don't stop the removing process | 273 | // Maybe the torrent is not seeded, but we catch the error to don't stop the removing process |