mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
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:
parent
7bdc52d0c2
commit
a08fa3be5d
@ -26,7 +26,7 @@ trait Capacity extends OutputStreamFileSystem {
|
|||||||
override def delete(path: String) = {
|
override def delete(path: String) = {
|
||||||
val freed = Settings.get.fileCost + size(path)
|
val freed = Settings.get.fileCost + size(path)
|
||||||
if (super.delete(path)) {
|
if (super.delete(path)) {
|
||||||
used -= freed
|
used = math.max(0, used - freed)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else false
|
else false
|
||||||
@ -45,6 +45,13 @@ trait Capacity extends OutputStreamFileSystem {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
override def close() {
|
||||||
|
super.close()
|
||||||
|
used = computeSize("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def load(nbt: NBTTagCompound) {
|
override def load(nbt: NBTTagCompound) {
|
||||||
try {
|
try {
|
||||||
ignoreCapacity = true
|
ignoreCapacity = true
|
||||||
@ -52,6 +59,8 @@ trait Capacity extends OutputStreamFileSystem {
|
|||||||
} finally {
|
} finally {
|
||||||
ignoreCapacity = false
|
ignoreCapacity = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
used = computeSize("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
override def save(nbt: NBTTagCompound) {
|
override def save(nbt: NBTTagCompound) {
|
||||||
@ -78,7 +87,7 @@ trait Capacity extends OutputStreamFileSystem {
|
|||||||
super.openOutputHandle(id, path, mode) match {
|
super.openOutputHandle(id, path, mode) match {
|
||||||
case None => None
|
case None => None
|
||||||
case Some(stream) =>
|
case Some(stream) =>
|
||||||
used += delta
|
used = math.max(0, used + delta)
|
||||||
if (mode == Mode.Append) {
|
if (mode == Mode.Append) {
|
||||||
stream.seek(stream.length())
|
stream.seek(stream.length())
|
||||||
}
|
}
|
||||||
|
@ -148,8 +148,8 @@ object FileSystem extends api.detail.FileSystemAPI {
|
|||||||
|
|
||||||
private class RamFileSystem(protected val capacity: Long)
|
private class RamFileSystem(protected val capacity: Long)
|
||||||
extends VirtualFileSystem
|
extends VirtualFileSystem
|
||||||
with Capacity
|
|
||||||
with Volatile
|
with Volatile
|
||||||
|
with Capacity
|
||||||
|
|
||||||
private class BufferedFileSystem(protected val fileRoot: io.File, protected val capacity: Long)
|
private class BufferedFileSystem(protected val fileRoot: io.File, protected val capacity: Long)
|
||||||
extends VirtualFileSystem
|
extends VirtualFileSystem
|
||||||
|
Loading…
x
Reference in New Issue
Block a user