diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/lib/process.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/lib/process.lua index 56361ebf7..e07e15098 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/lib/process.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/lib/process.lua @@ -43,7 +43,12 @@ function process.load(path, env, init, name) reason = "no exec command" else code = function() - return require("shell").execute(command, env, path) + local result = table.pack(require("shell").execute(command, env, path)) + if not result[1] then + error(result[2], 0) + else + return table.unpack(result, 1, result.n) + end end end else diff --git a/src/main/scala/li/cil/oc/server/fs/Buffered.scala b/src/main/scala/li/cil/oc/server/fs/Buffered.scala index 9d1b00599..fd4fbf1b4 100644 --- a/src/main/scala/li/cil/oc/server/fs/Buffered.scala +++ b/src/main/scala/li/cil/oc/server/fs/Buffered.scala @@ -1,6 +1,7 @@ package li.cil.oc.server.fs import java.io +import java.io.FileNotFoundException import li.cil.oc.api.fs.Mode import net.minecraft.nbt.NBTTagCompound @@ -45,17 +46,22 @@ trait Buffered extends OutputStreamFileSystem { else if (!exists(childPath) || !isDirectory(childPath)) { openOutputHandle(0, childPath, Mode.Write) match { case Some(stream) => - val in = new io.FileInputStream(childFile) - val buffer = new Array[Byte](8 * 1024) - var read = 0 - do { - read = in.read(buffer) - if (read > 0) { - if (read == buffer.length) stream.write(buffer) - else stream.write(buffer.view(0, read).toArray) - } - } while (read >= 0) - in.close() + try { + val in = new io.FileInputStream(childFile) + val buffer = new Array[Byte](8 * 1024) + var read = 0 + do { + read = in.read(buffer) + if (read > 0) { + if (read == buffer.length) stream.write(buffer) + else stream.write(buffer.view(0, read).toArray) + } + } while (read >= 0) + in.close() + } + catch { + case _: FileNotFoundException => // File got deleted in the meantime. + } stream.close() setLastModified(childPath, childFile.lastModified()) case _ => // File is open for writing.