-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.js
More file actions
30 lines (25 loc) · 754 Bytes
/
clean.js
File metadata and controls
30 lines (25 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var config = require('./config');
var mongoose = require('mongoose');
var Promise = require('bluebird');
var file = require('./util/file');
var exec = Promise.promisify(require('child_process').execFile);
mongoose.connect(config.db.uri, function() {
var Item = require('./models/item');
console.log('connected to mongo');
return Item.all()
.then(function(items) {
console.log('got all items');
return Promise.all(items.map(function(item) {
item.path = null;
item.files = [];
return item.saveWithPromise();
}))
})
.then(function() {
console.log('removing storage');
return exec('rm', ['-fr', config.storage.path]);
})
.then(function() {
process.exit(0);
})
});