diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-13 21:45:23 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-13 21:45:23 +0200 |
commit | 82221ac920ad2e6bafc742a09fa1636899d4173e (patch) | |
tree | 4c7928dd457d9e3b223bd2835ae0d23cd3c87d41 | |
parent | 0b10407e465d639cd141fe8821a8504a0b7b83fb (diff) | |
download | PeerTube-82221ac920ad2e6bafc742a09fa1636899d4173e.tar.gz PeerTube-82221ac920ad2e6bafc742a09fa1636899d4173e.tar.zst PeerTube-82221ac920ad2e6bafc742a09fa1636899d4173e.zip |
Update clean script
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | scripts/danger/clean/cleaner.js | 23 | ||||
-rwxr-xr-x | scripts/danger/clean/dev.sh | 7 | ||||
-rwxr-xr-x | scripts/danger/clean/modules.sh | 2 | ||||
-rwxr-xr-x | scripts/danger/clean/prod.sh | 7 | ||||
-rwxr-xr-x | scripts/danger/clean/server.sh | 8 | ||||
-rwxr-xr-x | scripts/help.sh | 3 | ||||
-rw-r--r-- | server/controllers/api/v1/videos.js | 3 |
8 files changed, 43 insertions, 14 deletions
diff --git a/package.json b/package.json index 886becf41..1111c7a6d 100644 --- a/package.json +++ b/package.json | |||
@@ -24,7 +24,8 @@ | |||
24 | "clean:client": "scripty", | 24 | "clean:client": "scripty", |
25 | "clean:server:test": "scripty", | 25 | "clean:server:test": "scripty", |
26 | "watch:client": "SCRIPTY_PARALLEL=true scripty", | 26 | "watch:client": "SCRIPTY_PARALLEL=true scripty", |
27 | "danger:clean:server": "scripty", | 27 | "danger:clean:dev": "scripty", |
28 | "danger:clean:prod": "scripty", | ||
28 | "danger:clean:modules": "scripty", | 29 | "danger:clean:modules": "scripty", |
29 | "play": "scripty", | 30 | "play": "scripty", |
30 | "dev": "scripty", | 31 | "dev": "scripty", |
@@ -60,6 +61,7 @@ | |||
60 | "password-generator": "^2.0.2", | 61 | "password-generator": "^2.0.2", |
61 | "request": "^2.57.0", | 62 | "request": "^2.57.0", |
62 | "request-replay": "^1.0.2", | 63 | "request-replay": "^1.0.2", |
64 | "rimraf": "^2.5.4", | ||
63 | "scripty": "^1.5.0", | 65 | "scripty": "^1.5.0", |
64 | "ursa": "^0.9.1", | 66 | "ursa": "^0.9.1", |
65 | "winston": "^2.1.1", | 67 | "winston": "^2.1.1", |
diff --git a/scripts/danger/clean/cleaner.js b/scripts/danger/clean/cleaner.js new file mode 100644 index 000000000..a63c478e0 --- /dev/null +++ b/scripts/danger/clean/cleaner.js | |||
@@ -0,0 +1,23 @@ | |||
1 | const rimraf = require('rimraf') | ||
2 | const mongoose = require('mongoose') | ||
3 | |||
4 | const constants = require('../../../server/initializers/constants') | ||
5 | |||
6 | const mongodbUrl = 'mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME | ||
7 | mongoose.connect(mongodbUrl, function () { | ||
8 | console.info('Deleting MongoDB %s database.', constants.CONFIG.DATABASE.DBNAME) | ||
9 | mongoose.connection.db.dropDatabase(function () { | ||
10 | mongoose.connection.close() | ||
11 | }) | ||
12 | }) | ||
13 | |||
14 | const STORAGE = constants.CONFIG.STORAGE | ||
15 | Object.keys(STORAGE).forEach(function (storage) { | ||
16 | const storageDir = STORAGE[storage] | ||
17 | |||
18 | rimraf(storageDir, function (err) { | ||
19 | if (err) throw err | ||
20 | |||
21 | console.info('Deleting %s.', storageDir) | ||
22 | }) | ||
23 | }) | ||
diff --git a/scripts/danger/clean/dev.sh b/scripts/danger/clean/dev.sh new file mode 100755 index 000000000..5f09565cf --- /dev/null +++ b/scripts/danger/clean/dev.sh | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | read -p "This will remove all directories and Mongo database. Are you sure? " -n 1 -r | ||
4 | |||
5 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then | ||
6 | NODE_ENV=test node "./scripts/danger/clean/cleaner" | ||
7 | fi | ||
diff --git a/scripts/danger/clean/modules.sh b/scripts/danger/clean/modules.sh index 429044b3f..99555a693 100755 --- a/scripts/danger/clean/modules.sh +++ b/scripts/danger/clean/modules.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | read -p "This will remove all node and typescript modules. Are you sure? " -n 1 -r | 3 | read -p "This will remove all node server and client modules. Are you sure? " -n 1 -r |
4 | 4 | ||
5 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then | 5 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then |
6 | rm -rf node_modules client/node_modules | 6 | rm -rf node_modules client/node_modules |
diff --git a/scripts/danger/clean/prod.sh b/scripts/danger/clean/prod.sh new file mode 100755 index 000000000..e6c92671d --- /dev/null +++ b/scripts/danger/clean/prod.sh | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | read -p "This will remove all directories and Mongo database. Are you sure? " -n 1 -r | ||
4 | |||
5 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then | ||
6 | NODE_ENV=production node "./scripts/danger/clean/cleaner" | ||
7 | fi | ||
diff --git a/scripts/danger/clean/server.sh b/scripts/danger/clean/server.sh deleted file mode 100755 index 1a0576112..000000000 --- a/scripts/danger/clean/server.sh +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | read -p "This will remove certs, uploads, database (dev) and logs. Are you sure? " -n 1 -r | ||
4 | |||
5 | if [[ "$REPLY" =~ ^[Yy]$ ]]; then | ||
6 | rm -rf ./certs ./logs ./uploads | ||
7 | printf "use peertube-dev;\ndb.dropDatabase();" | mongo | ||
8 | fi | ||
diff --git a/scripts/help.sh b/scripts/help.sh index a2c8e4df0..6e124c276 100755 --- a/scripts/help.sh +++ b/scripts/help.sh | |||
@@ -9,7 +9,8 @@ printf " clean -> Clean the application\n" | |||
9 | printf " clean:client -> Clean the client build files (dist directory)\n" | 9 | printf " clean:client -> Clean the client build files (dist directory)\n" |
10 | printf " clean:server:test -> Clean certificates, logs, uploads and database of the test instances\n" | 10 | printf " clean:server:test -> Clean certificates, logs, uploads and database of the test instances\n" |
11 | printf " watch:client -> Watch the client files\n" | 11 | printf " watch:client -> Watch the client files\n" |
12 | printf " danger:clean:server -> /!\ Clean certificates, logs, uploads and database\n" | 12 | printf " danger:clean:dev -> /!\ Clean certificates, logs, uploads, thumbnails, torrents and database specified in the development environment\n" |
13 | printf " danger:clean:prod -> /!\ Clean certificates, logs, uploads, thumbnails, torrents and database specified by the production environment\n" | ||
13 | printf " danger:clean:modules -> /!\ Clean node and typescript modules\n" | 14 | printf " danger:clean:modules -> /!\ Clean node and typescript modules\n" |
14 | printf " play -> Run 3 fresh nodes so that you can test the communication between them\n" | 15 | printf " play -> Run 3 fresh nodes so that you can test the communication between them\n" |
15 | printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n" | 16 | printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n" |
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index 70d22f139..d633af76d 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -116,9 +116,6 @@ function addVideo (req, res, next) { | |||
116 | 116 | ||
117 | ], function andFinally (err) { | 117 | ], function andFinally (err) { |
118 | if (err) { | 118 | if (err) { |
119 | // TODO unseed the video | ||
120 | // TODO remove thumbnail | ||
121 | // TODO delete from DB | ||
122 | logger.error('Cannot insert the video.') | 119 | logger.error('Cannot insert the video.') |
123 | return next(err) | 120 | return next(err) |
124 | } | 121 | } |