fixed opening files in write mode when using unbuffered mode (filesystem.bufferChanges = false), fixes #144

This commit is contained in:
Florian Nücke 2014-03-01 17:59:55 +01:00
parent c059c7b90b
commit 6f6727d1f0
2 changed files with 4 additions and 2 deletions

View File

@ -78,6 +78,9 @@ trait Capacity extends OutputStreamFileSystem {
case None => None case None => None
case Some(stream) => case Some(stream) =>
used += delta used += delta
if (mode == Mode.Append) {
stream.seek(stream.length())
}
Some(new CountingOutputHandle(this, stream)) Some(new CountingOutputHandle(this, stream))
} }
} }

View File

@ -23,8 +23,7 @@ trait FileOutputStreamFileSystem extends FileInputStreamFileSystem with OutputSt
override protected def openOutputHandle(id: Int, path: String, mode: Mode): Option[OutputHandle] = override protected def openOutputHandle(id: Int, path: String, mode: Mode): Option[OutputHandle] =
Some(new FileHandle(new RandomAccessFile(new io.File(root, path), mode match { Some(new FileHandle(new RandomAccessFile(new io.File(root, path), mode match {
case Mode.Append => "a" case Mode.Append | Mode.Write => "rw"
case Mode.Write => "w"
case _ => throw new IllegalArgumentException() case _ => throw new IllegalArgumentException()
}), this, id, path)) }), this, id, path))