Wrap pushItems in pcall
This commit is contained in:
@@ -363,9 +363,26 @@ function Storage:defrag(throttle)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local toMove = math.min(to.item.maxCount - to.item.count, from.item.count)
|
local toMove = math.min(to.item.maxCount - to.item.count, from.item.count)
|
||||||
from.device.pushItems(to.device.name, from.slot, toMove, to.slot)
|
local s, m = pcall(function()
|
||||||
to.item.count = to.item.count + toMove
|
from.device.pushItems(to.device.name, from.slot, toMove, to.slot)
|
||||||
from.item.count = from.item.count - toMove
|
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
|
if from.item.count <= 0 then
|
||||||
table.remove(providers, 1)
|
table.remove(providers, 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user