Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Fixed parallel saving corrupting files, but saving is slightly less p…
Browse files Browse the repository at this point in the history
…arallel. (with disk I/O involved, might not change that much)
  • Loading branch information
jglrxavpok committed Aug 9, 2020
1 parent 7980804 commit 73d1ac9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/main/kotlin/org/jglrxavpok/hephaistos/mca/RegionFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,20 @@ class RegionFile @Throws(AnvilException::class, IOException::class) constructor(
freeSectors += false // increase size of freeSectors
}
}
}

writeInt(position, dataSize)
writeByte(position+4, ZlibCompression)
writeBytes(position+5, dataOut.toByteArray())
writeInt(position, dataSize)
writeByte(position+4, ZlibCompression)
writeBytes(position+5, dataOut.toByteArray())

if(appendToEnd) { // we are at the EOF, we may have to add some padding
addPadding()
}
if(appendToEnd) { // we are at the EOF, we may have to add some padding
addPadding()
}

locations[location] = buildLocation(sectorStart, sectorCount)
writeLocation(column.x, column.z)
timestamps[location] = System.currentTimeMillis().toInt()
writeTimestamp(column.x, column.z)
locations[location] = buildLocation(sectorStart, sectorCount)
writeLocation(column.x, column.z)
timestamps[location] = System.currentTimeMillis().toInt()
writeTimestamp(column.x, column.z)

synchronized(file) {
// the data has been written, now free previous storage
for (i in previousSectorStart until previousSectorStart+previousSectorCount) {
freeSectors[i] = true
Expand Down

0 comments on commit 73d1ac9

Please sign in to comment.