Fixed tmp file system's usage counter not being properly reset when closed and not being recomputed on load, closes #471.

This commit is contained in:
Florian Nücke 2014-08-06 13:22:09 +02:00
parent 7bdc52d0c2
commit a08fa3be5d
2 changed files with 12 additions and 3 deletions

View File

@ -26,7 +26,7 @@ trait Capacity extends OutputStreamFileSystem {
override def delete(path: String) = {
val freed = Settings.get.fileCost + size(path)
if (super.delete(path)) {
used -= freed
used = math.max(0, used - freed)
true
}
else false
@ -45,6 +45,13 @@ trait Capacity extends OutputStreamFileSystem {
// ----------------------------------------------------------------------- //
override def close() {
super.close()
used = computeSize("/")
}
// ----------------------------------------------------------------------- //
override def load(nbt: NBTTagCompound) {
try {
ignoreCapacity = true
@ -52,6 +59,8 @@ trait Capacity extends OutputStreamFileSystem {
} finally {
ignoreCapacity = false
}
used = computeSize("/")
}
override def save(nbt: NBTTagCompound) {
@ -78,7 +87,7 @@ trait Capacity extends OutputStreamFileSystem {
super.openOutputHandle(id, path, mode) match {
case None => None
case Some(stream) =>
used += delta
used = math.max(0, used + delta)
if (mode == Mode.Append) {
stream.seek(stream.length())
}

View File

@ -148,8 +148,8 @@ object FileSystem extends api.detail.FileSystemAPI {
private class RamFileSystem(protected val capacity: Long)
extends VirtualFileSystem
with Capacity
with Volatile
with Capacity
private class BufferedFileSystem(protected val fileRoot: io.File, protected val capacity: Long)
extends VirtualFileSystem