From 2f187a196fca687b082ecfdc9d8709030f3d02fb Mon Sep 17 00:00:00 2001 From: Luca_S Date: Mon, 20 Apr 2020 22:47:23 +0200 Subject: [PATCH] defrag() now returns how many slots were saved --- milo/apis/storage.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/milo/apis/storage.lua b/milo/apis/storage.lua index c41ca8b..01aaf18 100644 --- a/milo/apis/storage.lua +++ b/milo/apis/storage.lua @@ -336,6 +336,7 @@ end -- defrags the storage system function Storage:defrag(throttle) local items = self:listProviders(throttle) + local slotsSaved = 0 for _, providers in pairs(items) do table.sort(providers, function(a, b) @@ -368,6 +369,7 @@ function Storage:defrag(throttle) if from.item.count <= 0 then table.remove(providers, 1) + slotsSaved = slotsSaved + 1 end table.sort(providers, function(a, b) @@ -375,6 +377,8 @@ function Storage:defrag(throttle) end) end end + + return slotsSaved end function Storage:updateCache(adapter, item, count)