forked from xdarklight/cm-update-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisable-build.js
60 lines (55 loc) · 1.51 KB
/
disable-build.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var Troll = require('troll-opt').Troll;
var models = require('./models/');
var buildInfo = (new Troll()).options(function(troll) {
troll.banner('Marks a build as disabled so it cannot be downloaded anymore.');
troll.opt('device', 'The device ID.', { type: 'string', required: true });
troll.opt('filename', 'The resulting filename.', { type: 'string', required: true });
troll.opt('subdirectory', 'The subdirectory from which the file can be downloaded.', { type: 'string' });
troll.opt('disable_incrementals', 'Disables the incrementals for this rom also.', { type: 'boolean' });
});
models.sequelize.sync().then(function() {
models.Rom.findAll({
include: [
{
model: models.RomVariant,
include: [
{
model: models.Device,
where: {
name: buildInfo.device,
}
},
],
where: {
subdirectory: buildInfo.subdirectory
}
}
],
where: {
filename: buildInfo.filename,
isActive: true,
}
}).then(function(roms) {
roms.forEach(function (rom) {
rom.isActive = false;
rom.save().then(function() {
console.log('Disabled ROM: ' + JSON.stringify(rom));
});
if (buildInfo.disable_incrementals) {
models.Incremental.update({
isActive: false,
}, {
// WHERE
targetRomId: rom.id,
}, {
// options
// We cannot validate here because our
// validator enforces that a sourceRomId
// etc. is set. This is the case, but the
// update-information does not have it.
validate: false,
});
}
});
});
});