]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Standard v6
authorChocobozzz <florian.bigard@gmail.com>
Sun, 7 Feb 2016 09:39:37 +0000 (10:39 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Sun, 7 Feb 2016 09:39:37 +0000 (10:39 +0100)
12 files changed:
helpers/logger.js
helpers/peertubeCrypto.js
initializers/checker.js
lib/poolRequests.js
lib/videos.js
lib/webtorrent.js
models/videos.js
package.json
tests/api/checkParams.js
tests/api/multiplePods.js
tests/api/singlePod.js
tests/api/utils.js

index fa5b5370835aab9e7c7a7aed1a7ecfe6cd58f4f3..436091730dcce1d33cec50d503192a11175b3265 100644 (file)
@@ -3,15 +3,16 @@
   'use strict'
 
   var config = require('config')
+  var path = require('path')
   var winston = require('winston')
   winston.emitErrs = true
 
-  var logDir = __dirname + '/../' + config.get('storage.logs')
+  var logDir = path.join(__dirname, '..', config.get('storage.logs'))
   var logger = new winston.Logger({
     transports: [
       new winston.transports.File({
         level: 'debug',
-        filename: logDir + '/all-logs.log',
+        filename: path.join(logDir, 'all-logs.log'),
         handleExceptions: true,
         json: true,
         maxsize: 5242880,
index 36271dba9ced037a20011bc57e607e56a5b3294b..9031f6ae5f46fc988cd0a9b32b096f84f56ff4f8 100644 (file)
@@ -5,11 +5,12 @@
   var crypto = require('crypto')
   var fs = require('fs')
   var openssl = require('openssl-wrapper')
+  var path = require('path')
   var ursa = require('ursa')
 
   var logger = require('./logger')
 
-  var certDir = __dirname + '/../' + config.get('storage.certs')
+  var certDir = path.join(__dirname, '..', config.get('storage.certs'))
   var algorithm = 'aes-256-ctr'
 
   var peertubeCrypto = {
index 7a09c02d14ad681d6524f642815da3a124db3715..f4458c5cfa729602e133346d1cc9e2412ea8956a 100644 (file)
@@ -3,6 +3,7 @@
 
   var config = require('config')
   var mkdirp = require('mkdirp')
+  var path = require('path')
 
   var checker = {
     checkConfig: checkConfig,
@@ -32,9 +33,9 @@
     var storages = config.get('storage')
 
     for (var key of Object.keys(storages)) {
-      var path = storages[key]
+      var dir = storages[key]
       try {
-        mkdirp.sync(__dirname + '/../' + path)
+        mkdirp.sync(path.join(__dirname, '..', dir))
       } catch (error) {
         // Do not use logger
         console.error('Cannot create ' + path + ':' + error)
index 5b7d5489d071766f6b91e3870045704c61d8f6a3..9ea41f383d9005d36316ff2922e2b12650f061b7 100644 (file)
@@ -41,7 +41,7 @@
         }
 
         // Remove the request of the other type
-        PoolRequests.removeById(id, function (err) {
+        PoolRequests.removeRequestById(id, function (err) {
           if (err) {
             logger.error('Cannot remove a pool request.', { error: err })
             return // Abort
@@ -49,7 +49,7 @@
         })
       } else {
         PoolRequests.create(id, type, request, function (err) {
-          logger.error('Cannot create a pool request.', { error: err })
+          if (err) logger.error('Cannot create a pool request.', { error: err })
           return // Abort
         })
       }
index 1bb6f249317dd58db99a55b96901a968e54b42d1..0e814335194051038dd8bf195ec7e859ba974e2f 100644 (file)
@@ -3,12 +3,13 @@
 
   var async = require('async')
   var config = require('config')
+  var path = require('path')
   var webtorrent = require('../lib/webtorrent')
 
   var logger = require('../helpers/logger')
   var Videos = require('../models/videos')
 
-  var uploadDir = __dirname + '/../' + config.get('storage.uploads')
+  var uploadDir = path.join(__dirname, '..', config.get('storage.uploads'))
 
   var videos = {
     seed: seed,
index 7cd38156ccc18483aaf3f6af24cfc27307a0f28c..083e5b77a3f27f8eac86b9e50170d02e3f784e21 100644 (file)
@@ -59,7 +59,7 @@
         process.exit()
       })
 
-      var webtorrent_process = spawn(__dirname + '/webtorrentProcess.js', host, port, { detached: true })
+      var webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true })
       webtorrent_process.stderr.on('data', function (data) {
         // logger.debug('Webtorrent process stderr: ', data.toString())
       })
index 6ea6283737c6840f3b6298fb1fa71b514d9355b1..ea1823e2780e92b6a5bfc77ea83473f14fd5edcf 100644 (file)
@@ -6,13 +6,14 @@
   var dz = require('dezalgo')
   var fs = require('fs')
   var mongoose = require('mongoose')
+  var path = require('path')
 
   var logger = require('../helpers/logger')
 
   var http = config.get('webserver.https') === true ? 'https' : 'http'
   var host = config.get('webserver.host')
   var port = config.get('webserver.port')
-  var uploadDir = __dirname + '/../' + config.get('storage.uploads')
+  var uploadDir = path.join(__dirname, '..', config.get('storage.uploads'))
 
   // ---------------------------------------------------------------------------
 
index 38ea52b36215220d2e02035b7e97e1a5fd4b0518..07cb00fa5a9f1a9650b3d925e5bed78bf9ac832d 100644 (file)
@@ -66,7 +66,7 @@
   "devDependencies": {
     "chai": "^3.3.0",
     "mocha": "^2.3.3",
-    "standard": "^5.1.0",
+    "standard": "^6.0.1",
     "supertest": "^1.1.0"
   },
   "standard": {
index 11fc68ff99a2033634130dcc0ab40be59d0e04e5..8ce1bd4768dfb9f6ee8b98497e64658da48052ce 100644 (file)
@@ -4,6 +4,7 @@
   var async = require('async')
   var chai = require('chai')
   var expect = chai.expect
+  var pathUtils = require('path')
   var request = require('supertest')
 
   var utils = require('./utils')
       describe('When searching a video', function () {
         it('Should fail with nothing', function (done) {
           request(url)
-            .get(path + '/search/')
+            .get(pathUtils.join(path, 'search'))
             .set('Accept', 'application/json')
             .expect(400, done)
         })
             description: 'my super description'
           }
           var attach = {
-            'input_video': __dirname + '/fixtures/video_short.webm'
+            'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
           }
           makePostRequest(path, data, attach, done)
         })
             description: 'my super description'
           }
           var attach = {
-            'input_video': __dirname + '/fixtures/video_short.webm'
+            'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
           }
           makePostRequest(path, data, attach, done)
         })
             name: 'my super name'
           }
           var attach = {
-            'input_video': __dirname + '/fixtures/video_short.webm'
+            'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
           }
           makePostRequest(path, data, attach, done)
         })
                          'very very very very very very very very very very very very very very very long'
           }
           var attach = {
-            'input_video': __dirname + '/fixtures/video_short.webm'
+            'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
           }
           makePostRequest(path, data, attach, done)
         })
             description: 'my super description'
           }
           var attach = {
-            'input_video': __dirname + '/../fixtures/video_short_fake.webm'
+            'input_video': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
           }
           makePostRequest(path, data, attach, done)
         })
             description: 'my super description'
           }
           var attach = {
-            'input_video': __dirname + '/fixtures/video_short.webm'
+            'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
           }
           makePostRequest(path, data, attach, function () {
-            attach.input_video = __dirname + '/fixtures/video_short.mp4'
+            attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4')
             makePostRequest(path, data, attach, function () {
-              attach.input_video = __dirname + '/fixtures/video_short.ogv'
+              attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv')
               makePostRequest(path, data, attach, done, true)
             }, true)
           }, true)
index 5070b450af2e21cbd63e4e02768eba5c6166ef03..7949da80a2c867c0dbba045273d00a360b91fa0a 100644 (file)
@@ -4,9 +4,10 @@
   var async = require('async')
   var chai = require('chai')
   var expect = chai.expect
+  var pathUtils = require('path')
 
   var utils = require('./utils')
-  var webtorrent = require(__dirname + '/../../lib/webtorrent')
+  var webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
   webtorrent.silent = true
 
   describe('Test multiple pods', function () {
index e5337256bd876576fb5d592419a3f283116b4c5a..f33aa8c7ae934f217a0296d39e35d3f845853619 100644 (file)
@@ -5,8 +5,9 @@
   var chai = require('chai')
   var expect = chai.expect
   var fs = require('fs')
+  var pathUtils = require('path')
 
-  var webtorrent = require(__dirname + '/../../lib/webtorrent')
+  var webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
   webtorrent.silent = true
 
   var utils = require('./utils')
       utils.removeVideo(url, video_id, function (err) {
         if (err) throw err
 
-        fs.readdir(__dirname + '/../../test1/uploads/', function (err, files) {
+        fs.readdir(pathUtils.join(__dirname, '../../test1/uploads/'), function (err, files) {
           if (err) throw err
 
           expect(files.length).to.equal(0)
index a1996b4d7f318b4fadc5d554a7c6992dbbfb7991..b71e943edd70098e73ee65b381f0b44ab560c645 100644 (file)
@@ -4,6 +4,7 @@
   var child_process = require('child_process')
   var exec = child_process.exec
   var fork = child_process.fork
+  var pathUtils = require('path')
   var request = require('supertest')
 
   var testUtils = {
@@ -22,7 +23,7 @@
   // ---------------------- Export functions --------------------
 
   function flushTests (callback) {
-    exec(__dirname + '/../../scripts/clean_test.sh', callback)
+    exec(pathUtils.join(__dirname, '../../scripts/clean_test.sh'), callback)
   }
 
   function getFriendsList (url, end) {
       detached: true
     }
 
-    var app = fork(__dirname + '/../../server.js', [], options)
+    var app = fork(pathUtils.join(__dirname, '../../server.js'), [], options)
     app.stdout.on('data', function onStdout (data) {
       var dont_continue = false
       // Check if all required sentences are here
       .set('Accept', 'application/json')
       .field('name', name)
       .field('description', description)
-      .attach('input_video', __dirname + '/fixtures/' + fixture)
+      .attach('input_video', pathUtils.join(__dirname, 'fixtures', fixture))
       .expect(201)
       .end(end)
   }