aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-02-07 10:39:37 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-02-07 10:39:37 +0100
commitb3077e417056f18225957f65419b87de72117fe3 (patch)
treebe00437c83175ca09b184df6fb21ffe149e11ff8
parentc5a8be2b6282d2042e469e1b7c1e7ce8795c026f (diff)
downloadPeerTube-b3077e417056f18225957f65419b87de72117fe3.tar.gz
PeerTube-b3077e417056f18225957f65419b87de72117fe3.tar.zst
PeerTube-b3077e417056f18225957f65419b87de72117fe3.zip
Standard v6
-rw-r--r--helpers/logger.js5
-rw-r--r--helpers/peertubeCrypto.js3
-rw-r--r--initializers/checker.js5
-rw-r--r--lib/poolRequests.js4
-rw-r--r--lib/videos.js3
-rw-r--r--lib/webtorrent.js2
-rw-r--r--models/videos.js3
-rw-r--r--package.json2
-rw-r--r--tests/api/checkParams.js19
-rw-r--r--tests/api/multiplePods.js3
-rw-r--r--tests/api/singlePod.js5
-rw-r--r--tests/api/utils.js7
12 files changed, 35 insertions, 26 deletions
diff --git a/helpers/logger.js b/helpers/logger.js
index fa5b53708..436091730 100644
--- a/helpers/logger.js
+++ b/helpers/logger.js
@@ -3,15 +3,16 @@
3 'use strict' 3 'use strict'
4 4
5 var config = require('config') 5 var config = require('config')
6 var path = require('path')
6 var winston = require('winston') 7 var winston = require('winston')
7 winston.emitErrs = true 8 winston.emitErrs = true
8 9
9 var logDir = __dirname + '/../' + config.get('storage.logs') 10 var logDir = path.join(__dirname, '..', config.get('storage.logs'))
10 var logger = new winston.Logger({ 11 var logger = new winston.Logger({
11 transports: [ 12 transports: [
12 new winston.transports.File({ 13 new winston.transports.File({
13 level: 'debug', 14 level: 'debug',
14 filename: logDir + '/all-logs.log', 15 filename: path.join(logDir, 'all-logs.log'),
15 handleExceptions: true, 16 handleExceptions: true,
16 json: true, 17 json: true,
17 maxsize: 5242880, 18 maxsize: 5242880,
diff --git a/helpers/peertubeCrypto.js b/helpers/peertubeCrypto.js
index 36271dba9..9031f6ae5 100644
--- a/helpers/peertubeCrypto.js
+++ b/helpers/peertubeCrypto.js
@@ -5,11 +5,12 @@
5 var crypto = require('crypto') 5 var crypto = require('crypto')
6 var fs = require('fs') 6 var fs = require('fs')
7 var openssl = require('openssl-wrapper') 7 var openssl = require('openssl-wrapper')
8 var path = require('path')
8 var ursa = require('ursa') 9 var ursa = require('ursa')
9 10
10 var logger = require('./logger') 11 var logger = require('./logger')
11 12
12 var certDir = __dirname + '/../' + config.get('storage.certs') 13 var certDir = path.join(__dirname, '..', config.get('storage.certs'))
13 var algorithm = 'aes-256-ctr' 14 var algorithm = 'aes-256-ctr'
14 15
15 var peertubeCrypto = { 16 var peertubeCrypto = {
diff --git a/initializers/checker.js b/initializers/checker.js
index 7a09c02d1..f4458c5cf 100644
--- a/initializers/checker.js
+++ b/initializers/checker.js
@@ -3,6 +3,7 @@
3 3
4 var config = require('config') 4 var config = require('config')
5 var mkdirp = require('mkdirp') 5 var mkdirp = require('mkdirp')
6 var path = require('path')
6 7
7 var checker = { 8 var checker = {
8 checkConfig: checkConfig, 9 checkConfig: checkConfig,
@@ -32,9 +33,9 @@
32 var storages = config.get('storage') 33 var storages = config.get('storage')
33 34
34 for (var key of Object.keys(storages)) { 35 for (var key of Object.keys(storages)) {
35 var path = storages[key] 36 var dir = storages[key]
36 try { 37 try {
37 mkdirp.sync(__dirname + '/../' + path) 38 mkdirp.sync(path.join(__dirname, '..', dir))
38 } catch (error) { 39 } catch (error) {
39 // Do not use logger 40 // Do not use logger
40 console.error('Cannot create ' + path + ':' + error) 41 console.error('Cannot create ' + path + ':' + error)
diff --git a/lib/poolRequests.js b/lib/poolRequests.js
index 5b7d5489d..9ea41f383 100644
--- a/lib/poolRequests.js
+++ b/lib/poolRequests.js
@@ -41,7 +41,7 @@
41 } 41 }
42 42
43 // Remove the request of the other type 43 // Remove the request of the other type
44 PoolRequests.removeById(id, function (err) { 44 PoolRequests.removeRequestById(id, function (err) {
45 if (err) { 45 if (err) {
46 logger.error('Cannot remove a pool request.', { error: err }) 46 logger.error('Cannot remove a pool request.', { error: err })
47 return // Abort 47 return // Abort
@@ -49,7 +49,7 @@
49 }) 49 })
50 } else { 50 } else {
51 PoolRequests.create(id, type, request, function (err) { 51 PoolRequests.create(id, type, request, function (err) {
52 logger.error('Cannot create a pool request.', { error: err }) 52 if (err) logger.error('Cannot create a pool request.', { error: err })
53 return // Abort 53 return // Abort
54 }) 54 })
55 } 55 }
diff --git a/lib/videos.js b/lib/videos.js
index 1bb6f2493..0e8143351 100644
--- a/lib/videos.js
+++ b/lib/videos.js
@@ -3,12 +3,13 @@
3 3
4 var async = require('async') 4 var async = require('async')
5 var config = require('config') 5 var config = require('config')
6 var path = require('path')
6 var webtorrent = require('../lib/webtorrent') 7 var webtorrent = require('../lib/webtorrent')
7 8
8 var logger = require('../helpers/logger') 9 var logger = require('../helpers/logger')
9 var Videos = require('../models/videos') 10 var Videos = require('../models/videos')
10 11
11 var uploadDir = __dirname + '/../' + config.get('storage.uploads') 12 var uploadDir = path.join(__dirname, '..', config.get('storage.uploads'))
12 13
13 var videos = { 14 var videos = {
14 seed: seed, 15 seed: seed,
diff --git a/lib/webtorrent.js b/lib/webtorrent.js
index 7cd38156c..083e5b77a 100644
--- a/lib/webtorrent.js
+++ b/lib/webtorrent.js
@@ -59,7 +59,7 @@
59 process.exit() 59 process.exit()
60 }) 60 })
61 61
62 var webtorrent_process = spawn(__dirname + '/webtorrentProcess.js', host, port, { detached: true }) 62 var webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true })
63 webtorrent_process.stderr.on('data', function (data) { 63 webtorrent_process.stderr.on('data', function (data) {
64 // logger.debug('Webtorrent process stderr: ', data.toString()) 64 // logger.debug('Webtorrent process stderr: ', data.toString())
65 }) 65 })
diff --git a/models/videos.js b/models/videos.js
index 6ea628373..ea1823e27 100644
--- a/models/videos.js
+++ b/models/videos.js
@@ -6,13 +6,14 @@
6 var dz = require('dezalgo') 6 var dz = require('dezalgo')
7 var fs = require('fs') 7 var fs = require('fs')
8 var mongoose = require('mongoose') 8 var mongoose = require('mongoose')
9 var path = require('path')
9 10
10 var logger = require('../helpers/logger') 11 var logger = require('../helpers/logger')
11 12
12 var http = config.get('webserver.https') === true ? 'https' : 'http' 13 var http = config.get('webserver.https') === true ? 'https' : 'http'
13 var host = config.get('webserver.host') 14 var host = config.get('webserver.host')
14 var port = config.get('webserver.port') 15 var port = config.get('webserver.port')
15 var uploadDir = __dirname + '/../' + config.get('storage.uploads') 16 var uploadDir = path.join(__dirname, '..', config.get('storage.uploads'))
16 17
17 // --------------------------------------------------------------------------- 18 // ---------------------------------------------------------------------------
18 19
diff --git a/package.json b/package.json
index 38ea52b36..07cb00fa5 100644
--- a/package.json
+++ b/package.json
@@ -66,7 +66,7 @@
66 "devDependencies": { 66 "devDependencies": {
67 "chai": "^3.3.0", 67 "chai": "^3.3.0",
68 "mocha": "^2.3.3", 68 "mocha": "^2.3.3",
69 "standard": "^5.1.0", 69 "standard": "^6.0.1",
70 "supertest": "^1.1.0" 70 "supertest": "^1.1.0"
71 }, 71 },
72 "standard": { 72 "standard": {
diff --git a/tests/api/checkParams.js b/tests/api/checkParams.js
index 11fc68ff9..8ce1bd476 100644
--- a/tests/api/checkParams.js
+++ b/tests/api/checkParams.js
@@ -4,6 +4,7 @@
4 var async = require('async') 4 var async = require('async')
5 var chai = require('chai') 5 var chai = require('chai')
6 var expect = chai.expect 6 var expect = chai.expect
7 var pathUtils = require('path')
7 var request = require('supertest') 8 var request = require('supertest')
8 9
9 var utils = require('./utils') 10 var utils = require('./utils')
@@ -119,7 +120,7 @@
119 describe('When searching a video', function () { 120 describe('When searching a video', function () {
120 it('Should fail with nothing', function (done) { 121 it('Should fail with nothing', function (done) {
121 request(url) 122 request(url)
122 .get(path + '/search/') 123 .get(pathUtils.join(path, 'search'))
123 .set('Accept', 'application/json') 124 .set('Accept', 'application/json')
124 .expect(400, done) 125 .expect(400, done)
125 }) 126 })
@@ -137,7 +138,7 @@
137 description: 'my super description' 138 description: 'my super description'
138 } 139 }
139 var attach = { 140 var attach = {
140 'input_video': __dirname + '/fixtures/video_short.webm' 141 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
141 } 142 }
142 makePostRequest(path, data, attach, done) 143 makePostRequest(path, data, attach, done)
143 }) 144 })
@@ -148,7 +149,7 @@
148 description: 'my super description' 149 description: 'my super description'
149 } 150 }
150 var attach = { 151 var attach = {
151 'input_video': __dirname + '/fixtures/video_short.webm' 152 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
152 } 153 }
153 makePostRequest(path, data, attach, done) 154 makePostRequest(path, data, attach, done)
154 }) 155 })
@@ -158,7 +159,7 @@
158 name: 'my super name' 159 name: 'my super name'
159 } 160 }
160 var attach = { 161 var attach = {
161 'input_video': __dirname + '/fixtures/video_short.webm' 162 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
162 } 163 }
163 makePostRequest(path, data, attach, done) 164 makePostRequest(path, data, attach, done)
164 }) 165 })
@@ -171,7 +172,7 @@
171 'very very very very very very very very very very very very very very very long' 172 'very very very very very very very very very very very very very very very long'
172 } 173 }
173 var attach = { 174 var attach = {
174 'input_video': __dirname + '/fixtures/video_short.webm' 175 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
175 } 176 }
176 makePostRequest(path, data, attach, done) 177 makePostRequest(path, data, attach, done)
177 }) 178 })
@@ -191,7 +192,7 @@
191 description: 'my super description' 192 description: 'my super description'
192 } 193 }
193 var attach = { 194 var attach = {
194 'input_video': __dirname + '/../fixtures/video_short_fake.webm' 195 'input_video': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
195 } 196 }
196 makePostRequest(path, data, attach, done) 197 makePostRequest(path, data, attach, done)
197 }) 198 })
@@ -202,12 +203,12 @@
202 description: 'my super description' 203 description: 'my super description'
203 } 204 }
204 var attach = { 205 var attach = {
205 'input_video': __dirname + '/fixtures/video_short.webm' 206 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
206 } 207 }
207 makePostRequest(path, data, attach, function () { 208 makePostRequest(path, data, attach, function () {
208 attach.input_video = __dirname + '/fixtures/video_short.mp4' 209 attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4')
209 makePostRequest(path, data, attach, function () { 210 makePostRequest(path, data, attach, function () {
210 attach.input_video = __dirname + '/fixtures/video_short.ogv' 211 attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv')
211 makePostRequest(path, data, attach, done, true) 212 makePostRequest(path, data, attach, done, true)
212 }, true) 213 }, true)
213 }, true) 214 }, true)
diff --git a/tests/api/multiplePods.js b/tests/api/multiplePods.js
index 5070b450a..7949da80a 100644
--- a/tests/api/multiplePods.js
+++ b/tests/api/multiplePods.js
@@ -4,9 +4,10 @@
4 var async = require('async') 4 var async = require('async')
5 var chai = require('chai') 5 var chai = require('chai')
6 var expect = chai.expect 6 var expect = chai.expect
7 var pathUtils = require('path')
7 8
8 var utils = require('./utils') 9 var utils = require('./utils')
9 var webtorrent = require(__dirname + '/../../lib/webtorrent') 10 var webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
10 webtorrent.silent = true 11 webtorrent.silent = true
11 12
12 describe('Test multiple pods', function () { 13 describe('Test multiple pods', function () {
diff --git a/tests/api/singlePod.js b/tests/api/singlePod.js
index e5337256b..f33aa8c7a 100644
--- a/tests/api/singlePod.js
+++ b/tests/api/singlePod.js
@@ -5,8 +5,9 @@
5 var chai = require('chai') 5 var chai = require('chai')
6 var expect = chai.expect 6 var expect = chai.expect
7 var fs = require('fs') 7 var fs = require('fs')
8 var pathUtils = require('path')
8 9
9 var webtorrent = require(__dirname + '/../../lib/webtorrent') 10 var webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
10 webtorrent.silent = true 11 webtorrent.silent = true
11 12
12 var utils = require('./utils') 13 var utils = require('./utils')
@@ -112,7 +113,7 @@
112 utils.removeVideo(url, video_id, function (err) { 113 utils.removeVideo(url, video_id, function (err) {
113 if (err) throw err 114 if (err) throw err
114 115
115 fs.readdir(__dirname + '/../../test1/uploads/', function (err, files) { 116 fs.readdir(pathUtils.join(__dirname, '../../test1/uploads/'), function (err, files) {
116 if (err) throw err 117 if (err) throw err
117 118
118 expect(files.length).to.equal(0) 119 expect(files.length).to.equal(0)
diff --git a/tests/api/utils.js b/tests/api/utils.js
index a1996b4d7..b71e943ed 100644
--- a/tests/api/utils.js
+++ b/tests/api/utils.js
@@ -4,6 +4,7 @@
4 var child_process = require('child_process') 4 var child_process = require('child_process')
5 var exec = child_process.exec 5 var exec = child_process.exec
6 var fork = child_process.fork 6 var fork = child_process.fork
7 var pathUtils = require('path')
7 var request = require('supertest') 8 var request = require('supertest')
8 9
9 var testUtils = { 10 var testUtils = {
@@ -22,7 +23,7 @@
22 // ---------------------- Export functions -------------------- 23 // ---------------------- Export functions --------------------
23 24
24 function flushTests (callback) { 25 function flushTests (callback) {
25 exec(__dirname + '/../../scripts/clean_test.sh', callback) 26 exec(pathUtils.join(__dirname, '../../scripts/clean_test.sh'), callback)
26 } 27 }
27 28
28 function getFriendsList (url, end) { 29 function getFriendsList (url, end) {
@@ -139,7 +140,7 @@
139 detached: true 140 detached: true
140 } 141 }
141 142
142 var app = fork(__dirname + '/../../server.js', [], options) 143 var app = fork(pathUtils.join(__dirname, '../../server.js'), [], options)
143 app.stdout.on('data', function onStdout (data) { 144 app.stdout.on('data', function onStdout (data) {
144 var dont_continue = false 145 var dont_continue = false
145 // Check if all required sentences are here 146 // Check if all required sentences are here
@@ -175,7 +176,7 @@
175 .set('Accept', 'application/json') 176 .set('Accept', 'application/json')
176 .field('name', name) 177 .field('name', name)
177 .field('description', description) 178 .field('description', description)
178 .attach('input_video', __dirname + '/fixtures/' + fixture) 179 .attach('input_video', pathUtils.join(__dirname, 'fixtures', fixture))
179 .expect(201) 180 .expect(201)
180 .end(end) 181 .end(end)
181 } 182 }