milo: cleanup
This commit is contained in:
@@ -248,16 +248,10 @@ function Storage:listItems(throttle)
|
||||
end
|
||||
|
||||
if #t > 0 then
|
||||
_G._debug('STORAGE: refreshing ' .. #t .. ' inventories')
|
||||
parallel.waitForAll(table.unpack(t))
|
||||
end
|
||||
|
||||
for _, adapter in self:onlineAdapters() do
|
||||
if adapter.dirty then
|
||||
_G._debug('STORAGE: refreshing ' .. adapter.name)
|
||||
--adapter:listItems(throttle)
|
||||
--adapter.dirty = false
|
||||
end
|
||||
local rcache = adapter.cache or { }
|
||||
for key,v in pairs(rcache) do
|
||||
local entry = cache[key]
|
||||
@@ -274,7 +268,7 @@ function Storage:listItems(throttle)
|
||||
end
|
||||
end
|
||||
itemDB:flush()
|
||||
_G._debug('STORAGE: refresh in ' .. timer())
|
||||
_G._debug('STORAGE: refresh ' .. #t .. ' inventories in ' .. timer())
|
||||
|
||||
self.dirty = false
|
||||
self.cache = cache
|
||||
@@ -330,19 +324,8 @@ function Storage:updateCache(adapter, item, count)
|
||||
end
|
||||
|
||||
function Storage:_sn(name)
|
||||
if not name then
|
||||
error('Invalid target', 3)
|
||||
end
|
||||
|
||||
local node = self.nodes[name]
|
||||
if node and node.displayName then
|
||||
return node.displayName
|
||||
end
|
||||
local t = { name:match(':(.+)_(%d+)$') }
|
||||
if #t ~= 2 then
|
||||
return name
|
||||
end
|
||||
return table.concat(t, '_')
|
||||
return node and node.displayName or name
|
||||
end
|
||||
|
||||
local function isValidTransfer(adapter, target)
|
||||
|
||||
@@ -80,8 +80,7 @@ function ExportTask:cycle(context)
|
||||
end
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug('Importer error')
|
||||
_G._debug(m)
|
||||
_G._debug('EXPORTER error: ' .. m)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local Milo = require('milo')
|
||||
local itemDB = require('itemDB')
|
||||
local Milo = require('milo')
|
||||
|
||||
local ImportTask = {
|
||||
name = 'importer',
|
||||
@@ -42,25 +43,30 @@ function ImportTask:cycle(context)
|
||||
return itemMatchesFilter(item)
|
||||
end
|
||||
|
||||
local list = node.adapter.list()
|
||||
|
||||
local function importSlot(slotNo)
|
||||
local item = node.adapter.getItemMeta(slotNo)
|
||||
local item = itemDB:get(list[slotNo], function()
|
||||
return node.adapter.getItemMeta(slotNo)
|
||||
end)
|
||||
if item and matchesFilter(item) then
|
||||
context.storage:import(node, slotNo, item.count, item)
|
||||
end
|
||||
end
|
||||
|
||||
if type(entry.slot) == 'number' then
|
||||
importSlot(entry.slot)
|
||||
if list[entry.slot] then
|
||||
importSlot(entry.slot)
|
||||
end
|
||||
else
|
||||
for i in pairs(node.adapter.list()) do
|
||||
for i in pairs(list) do
|
||||
importSlot(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
if not s and m then
|
||||
_G._debug('Importer error')
|
||||
_G._debug(m)
|
||||
_G._debug('IMPORTER error: ' .. m)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,10 +8,10 @@ local RefreshTask = {
|
||||
function RefreshTask:cycle(context)
|
||||
local now = os.clock()
|
||||
|
||||
for node, adapter in context.storage:onlineAdapters() do
|
||||
for node, adapter in context.storage:onlineAdapters() do
|
||||
if node.refreshInterval then
|
||||
if not adapter.lastRefresh or adapter.lastRefresh + node.refreshInterval < now then
|
||||
_G._debug('REFRESHER: ' .. adapter.name)
|
||||
_G._debug('REFRESHER: ' .. node.displayName or node.name)
|
||||
context.storage.dirty = true
|
||||
adapter.dirty = true
|
||||
adapter.lastRefresh = now
|
||||
|
||||
Reference in New Issue
Block a user