Skip to content

Node.js based forum software built for the modern web

fix: don't allow duplicate upgrade script names

Barış Soner Uşaklı8887f0edaa1b
diff --git a/src/upgrade.js b/src/upgrade.js
index f85ca13f19..7c1563bd0e 100644
--- a/src/upgrade.js
+++ b/src/upgrade.js
@@ -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);
};