Describe the bug
When a computer is writing to a file during an autosave, the write will generate a Lua exception bad argument #2 to 'write' (string expected, got light userdata)
To Reproduce
Steps to reproduce the behavior:
Build a computer with a CPU, single stick of memory, and a populated hard drive
Set your autosave interval to 5 minutes
Run the following code:
fs = filesystem
if fs.initFileSystem("/dev") == false then
computer.panic("Could not initialize /dev")
end
drives = fs.childs("/dev")
for idx, drive in pairs(fs.childs("/dev")) do
if drive == "serial" then table.remove(drives, idx) end
end
function getTime()
timestamp, dateTime, ISOTime = computer.magicTime()
return dateTime
end
function logTime()
handle:write(getTime() .. "\n")
end
while true do
status, err = pcall(logTime)
if not status then
local errString = string.format("%s: %s", getTime(), err)
print(errString)
end
event.pull(1)
end
4. When the autosave happens, a write should generate the error. The test.txt file will be overwritten with about 1kb of 0x00 bytes.
**Expected behavior**
I expect autosaves to not impact filesystem writes other than a short delay.
I expect filesystem writes to write only the data provided in the function call and not corrupt the open file.
**Additional context**
Using Jenkins build 12.
Describe the bug When a computer is writing to a file during an autosave, the write will generate a Lua exception
bad argument #2 to 'write' (string expected, got light userdata)
To Reproduce Steps to reproduce the behavior:
drives = fs.childs("/dev")
for idx, drive in pairs(fs.childs("/dev")) do if drive == "serial" then table.remove(drives, idx) end end
for i = 1, #drives do print(drives[i]) end
fs.mount("/dev/" .. drives[1], "/")
handle = fs.open("/test.txt", "w") errorHandle = fs.open("/error_timestamps.txt", "w")
function getTime() timestamp, dateTime, ISOTime = computer.magicTime() return dateTime end
function logTime() handle:write(getTime() .. "\n") end
while true do status, err = pcall(logTime) if not status then local errString = string.format("%s: %s", getTime(), err) print(errString) end event.pull(1) end