From a26b87436acdf7a9a586ed3e306565db1a569971 Mon Sep 17 00:00:00 2001 From: d87 Date: Wed, 9 Sep 2020 15:35:52 +0700 Subject: [PATCH] Updated /apt purge to work with sets --- migrations.lua | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/migrations.lua b/migrations.lua index 64c807a..4c4422b 100644 --- a/migrations.lua +++ b/migrations.lua @@ -343,20 +343,15 @@ end local cleanOpts = function(opts, status, list) if not opts.assignto then return end - if type(opts.assignto) == "string" then - local slot = opts.assignto - if not list[slot] then opts.assignto = { } end - else - local i = 1 - while (i <= #opts.assignto) do - local slot = opts.assignto[i] - if not list[slot] then - table.remove(opts.assignto, i) - i = i - 1 - end - i = i + 1 + local toRemove = {} + for slot, enabled in pairs(opts.assignto) do + if not list[slot] then + table.insert(toRemove, slot) end end + for _, slot in ipairs(toRemove) do + opts.assignto[slot] = nil + end end function Aptechka.PurgeDeadAssignments(searchAllClasses)