fix: don't allow duplicate upgrade script names

This commit is contained in:
Barış Soner Uşaklı
2020-08-07 18:57:40 -04:00
parent f4c986a79a
commit 8887f0edaa

View File

@@ -41,6 +41,23 @@ Upgrade.getAll = function (callback) {
}));
},
async.apply(Upgrade.appendPluginScripts),
function (files, next) {
// check duplicates and error
const seen = {};
const dupes = [];
files.forEach((file) => {
if (seen[file]) {
dupes.push(file);
} else {
seen[file] = true;
}
});
if (dupes.length) {
winston.error('Found duplicate upgrade scripts\n' + dupes);
return next(new Error('[[error:duplicate-upgrade-scripts]]'));
}
setImmediate(next);
},
], callback);
};