milo: fix cached transfer locations not getting uncached
This commit is contained in:
@@ -102,6 +102,11 @@ end
|
|||||||
function Storage:initStorage()
|
function Storage:initStorage()
|
||||||
local online = true
|
local online = true
|
||||||
|
|
||||||
|
-- unknown why this is not working below
|
||||||
|
for _,v in pairs(device) do
|
||||||
|
v.transferLocations = nil
|
||||||
|
end
|
||||||
|
|
||||||
for k,v in pairs(self.nodes) do
|
for k,v in pairs(self.nodes) do
|
||||||
if v.mtype ~= 'hidden' then
|
if v.mtype ~= 'hidden' then
|
||||||
if v.adapter then
|
if v.adapter then
|
||||||
@@ -337,12 +342,10 @@ end
|
|||||||
|
|
||||||
local function isValidTransfer(adapter, target)
|
local function isValidTransfer(adapter, target)
|
||||||
-- lazily cache transfer locations
|
-- lazily cache transfer locations
|
||||||
local transferLocations = adapter.transferLocations
|
if not adapter.transferLocations then
|
||||||
if not transferLocations then
|
adapter.transferLocations = adapter.getTransferLocations()
|
||||||
transferLocations = adapter.getTransferLocations()
|
|
||||||
adapter.transferLocations = transferLocations
|
|
||||||
end
|
end
|
||||||
for _,v in pairs(transferLocations) do
|
for _,v in pairs(adapter.transferLocations) do
|
||||||
if v == target then
|
if v == target then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -563,16 +566,15 @@ function Storage:trash(source, slot, count, item)
|
|||||||
local amount = 0
|
local amount = 0
|
||||||
if target and target.adapter and target.adapter.online then
|
if target and target.adapter and target.adapter.online then
|
||||||
local s, m = pcall(function()
|
local s, m = pcall(function()
|
||||||
_G._debug('TRA: %s(%d): %s%s -> %s in %s',
|
|
||||||
item.displayName or item.name, count, self:_sn(source.name),
|
|
||||||
slot and string.format('[%d]', slot) or '[*]', self:_sn(target.name), Util.round(timer(), 2))
|
|
||||||
|
|
||||||
--_G._debug('TRA: %s[%d] (%d)', self:_sn(source.name), slot, count or 64)
|
|
||||||
if isValidTransfer(source.adapter, target.name) then
|
if isValidTransfer(source.adapter, target.name) then
|
||||||
amount = source.adapter.pushItems(target.name, slot, count)
|
amount = source.adapter.pushItems(target.name, slot, count)
|
||||||
else
|
else
|
||||||
amount = target.adapter.pullItems(source.name, slot, count)
|
amount = target.adapter.pullItems(source.name, slot, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
_G._debug('TRA: %s(%d): %s%s -> %s in %s',
|
||||||
|
item.displayName or item.name, amount, self:_sn(source.name),
|
||||||
|
slot and string.format('[%d]', slot) or '[*]', self:_sn(target.name), Util.round(timer(), 2))
|
||||||
end)
|
end)
|
||||||
if not s and m then
|
if not s and m then
|
||||||
_G._debug(m)
|
_G._debug(m)
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ local function client(socket)
|
|||||||
if context.storage:import(node, data.slot, slot.count, slot) > 0 then
|
if context.storage:import(node, data.slot, slot.count, slot) > 0 then
|
||||||
local item = Milo:getItem(slot)
|
local item = Milo:getItem(slot)
|
||||||
if item then
|
if item then
|
||||||
|
-- TODO: This generates multile messages for the same item
|
||||||
|
-- use a callback system using a UID for the message
|
||||||
|
|
||||||
socket:write({
|
socket:write({
|
||||||
type = 'received',
|
type = 'received',
|
||||||
key = item.key,
|
key = item.key,
|
||||||
|
|||||||
Reference in New Issue
Block a user