defrag() now returns how many slots were saved
This commit is contained in:
@@ -336,6 +336,7 @@ end
|
|||||||
-- defrags the storage system
|
-- defrags the storage system
|
||||||
function Storage:defrag(throttle)
|
function Storage:defrag(throttle)
|
||||||
local items = self:listProviders(throttle)
|
local items = self:listProviders(throttle)
|
||||||
|
local slotsSaved = 0
|
||||||
|
|
||||||
for _, providers in pairs(items) do
|
for _, providers in pairs(items) do
|
||||||
table.sort(providers, function(a, b)
|
table.sort(providers, function(a, b)
|
||||||
@@ -368,6 +369,7 @@ function Storage:defrag(throttle)
|
|||||||
|
|
||||||
if from.item.count <= 0 then
|
if from.item.count <= 0 then
|
||||||
table.remove(providers, 1)
|
table.remove(providers, 1)
|
||||||
|
slotsSaved = slotsSaved + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
table.sort(providers, function(a, b)
|
table.sort(providers, function(a, b)
|
||||||
@@ -375,6 +377,8 @@ function Storage:defrag(throttle)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return slotsSaved
|
||||||
end
|
end
|
||||||
|
|
||||||
function Storage:updateCache(adapter, item, count)
|
function Storage:updateCache(adapter, item, count)
|
||||||
|
|||||||
Reference in New Issue
Block a user