mirror of
https://github.com/LDDestroier/CC/
synced 2025-06-09 22:34:04 +00:00
Ensure that channel files are closed if terminated
This commit is contained in:
parent
4e0369e7d2
commit
79b3e2822c
98
disknet.lua
98
disknet.lua
@ -159,64 +159,74 @@ disknet.receive = function(channel)
|
|||||||
|
|
||||||
loadFList()
|
loadFList()
|
||||||
|
|
||||||
while true do
|
local good, goddamnit = pcall(function()
|
||||||
for i = 1, #fList do
|
while true do
|
||||||
contents = fList[i].readAll()
|
for i = 1, #fList do
|
||||||
if contents ~= "" then
|
contents = fList[i].readAll()
|
||||||
fList[i].close()
|
if contents ~= "" then
|
||||||
fList[i] = fs.open(pList[i], "r")
|
fList[i].close()
|
||||||
contents = textutils.unserialize(fList[i].readAll())
|
fList[i] = fs.open(pList[i], "r")
|
||||||
if type(contents) == "table" then
|
contents = textutils.unserialize(fList[i].readAll())
|
||||||
if contents[1] then
|
if type(contents) == "table" then
|
||||||
if not output then
|
if contents[1] then
|
||||||
for look = 1, #contents do
|
if not output then
|
||||||
if (contents[look].uniqueID ~= uniqueID) and (not msgCheckList[contents[look].messageID]) then
|
for look = 1, #contents do
|
||||||
if getTime() - (contents[look].time or 0) <= 0.001 then
|
if (contents[look].uniqueID ~= uniqueID) and (not msgCheckList[contents[look].messageID]) then
|
||||||
msgCheckList[contents[look].messageID] = true
|
if getTime() - (contents[look].time or 0) <= 0.001 then
|
||||||
output = {}
|
msgCheckList[contents[look].messageID] = true
|
||||||
for k,v in pairs(contents[look]) do
|
output = {}
|
||||||
output[k] = v
|
for k,v in pairs(contents[look]) do
|
||||||
|
output[k] = v
|
||||||
|
end
|
||||||
|
break
|
||||||
end
|
end
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- delete old msesages
|
-- delete old msesages
|
||||||
doRewrite = false
|
doRewrite = false
|
||||||
for t = #contents, 1, -1 do
|
for t = #contents, 1, -1 do
|
||||||
if getTime() - (contents[t].time or 0) > 0.001 then
|
if getTime() - (contents[t].time or 0) > 0.001 then
|
||||||
msgCheckList[contents[t].messageID] = nil
|
msgCheckList[contents[t].messageID] = nil
|
||||||
table.remove(contents, t)
|
table.remove(contents, t)
|
||||||
doRewrite = true
|
doRewrite = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
if doRewrite then
|
||||||
if doRewrite then
|
writeFile(pList[i], textutils.serialize(contents))
|
||||||
writeFile(pList[i], textutils.serialize(contents))
|
end
|
||||||
end
|
if output then
|
||||||
if output then
|
for i = 1, #fList do
|
||||||
for i = 1, #fList do
|
fList[i].close()
|
||||||
fList[i].close()
|
end
|
||||||
|
fList, pList = {}, {}
|
||||||
|
break
|
||||||
end
|
end
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if output then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
os.queueEvent("")
|
||||||
|
os.pullEvent("")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if output then
|
end)
|
||||||
break
|
|
||||||
else
|
|
||||||
os.queueEvent("")
|
|
||||||
os.pullEvent("")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if contents then
|
if good then
|
||||||
return output.message, output.channel, output.id, output.time
|
if contents then
|
||||||
|
return output.message, output.channel, output.id, output.time
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return nil
|
for i = 1, #fList do
|
||||||
|
fList[i].close()
|
||||||
|
end
|
||||||
|
error(goddamnit, 0)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error(grr)
|
error(grr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user