Wrap pushItems in pcall

This commit is contained in:
Luca_S
2020-05-04 22:22:21 +02:00
parent 1d1a770e4b
commit db3c43f8c3

View File

@@ -363,9 +363,26 @@ function Storage:defrag(throttle)
end
local toMove = math.min(to.item.maxCount - to.item.count, from.item.count)
from.device.pushItems(to.device.name, from.slot, toMove, to.slot)
to.item.count = to.item.count + toMove
from.item.count = from.item.count - toMove
local s, m = pcall(function()
from.device.pushItems(to.device.name, from.slot, toMove, to.slot)
end)
if not s and m then
_G._syslog(m)
end
if s then
to.item.count = to.item.count + toMove
from.item.count = from.item.count - toMove
else
-- Do not try to send to the target again after it failed
for i = 2, #providers do
if to == providers[i] then
table.remove(providers, i)
break
end
end
end
if from.item.count <= 0 then
table.remove(providers, 1)