Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .run/javasteam [formatKotlin].run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="javasteam [formatKotlin]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="formatKotlin" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,7 @@ class ContentDownloader(val steamClient: SteamClient) {

val chunkID = Strings.toHex(chunk.chunkID)

val chunkInfo = ChunkData(chunk)

var outputChunkData = ByteArray(chunkInfo.uncompressedLength)
var outputChunkData = ByteArray(chunk.uncompressedLength)
var writtenBytes = 0

do {
Expand All @@ -544,10 +542,10 @@ class ContentDownloader(val steamClient: SteamClient) {
try {
connection = cdnPool.getConnection().await()

outputChunkData = ByteArray(chunkInfo.uncompressedLength)
outputChunkData = ByteArray(chunk.uncompressedLength)
writtenBytes = cdnPool.cdnClient.downloadDepotChunk(
depotId = depot.depotId,
chunk = chunkInfo,
chunk = chunk,
server = connection!!,
destination = outputChunkData,
depotKey = depot.depotKey,
Expand Down Expand Up @@ -587,7 +585,7 @@ class ContentDownloader(val steamClient: SteamClient) {
fileStreamData.fileStream = randomAccessFile.channel
}

fileStreamData.fileStream?.position(chunkInfo.offset)
fileStreamData.fileStream?.position(chunk.offset)
fileStreamData.fileStream?.write(ByteBuffer.wrap(outputChunkData, 0, writtenBytes))
} finally {
fileStreamData.fileLock.release()
Expand Down Expand Up @@ -715,7 +713,7 @@ class ContentDownloader(val steamClient: SteamClient) {
throw CancellationException("Unable to download manifest $manifestId for depot $depotId")
}

val newProtoManifest = DepotManifest(depotManifest)
val newProtoManifest = depotManifest
steamClient.configuration.depotManifestProvider.updateManifest(newProtoManifest)

return@async newProtoManifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import `in`.dragonbra.javasteam.types.DepotManifest
import `in`.dragonbra.javasteam.util.compat.readNBytesCompat
import `in`.dragonbra.javasteam.util.log.LogManager
import `in`.dragonbra.javasteam.util.log.Logger
import `in`.dragonbra.javasteam.util.stream.MemoryStream
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.IOException
Expand Down Expand Up @@ -190,7 +191,11 @@ class FileManifestProvider(private val file: Path) : IManifestProvider {
}
}
// add manifest as uncompressed data
zipUncompressed(zip, getEntryName(manifest.depotID, manifest.manifestGID), manifest.toByteArray())
MemoryStream().use { ms ->
manifest.serialize(ms.asOutputStream())

zipUncompressed(zip, getEntryName(manifest.depotID, manifest.manifestGID), ms.toByteArray())
}
}
// save all data to the file
try {
Expand Down
77 changes: 22 additions & 55 deletions src/main/java/in/dragonbra/javasteam/types/ChunkData.kt
Original file line number Diff line number Diff line change
@@ -1,55 +1,22 @@
package `in`.dragonbra.javasteam.types

/**
* Represents a single chunk within a file.
*/
class ChunkData {

/**
* Gets or sets the SHA-1 hash chunk id.
*/
val chunkID: ByteArray?

/**
* Gets or sets the expected Adler32 checksum of this chunk.
*/
val checksum: Int

/**
* Gets or sets the chunk offset.
*/
val offset: Long

/**
* Gets or sets the compressed length of this chunk.
*/
val compressedLength: Int

/**
* Gets or sets the decompressed length of this chunk.
*/
val uncompressedLength: Int

@JvmOverloads
constructor(
chunkID: ByteArray? = null,
checksum: Int = 0,
offset: Long = 0L,
compressedLength: Int = 0,
uncompressedLength: Int = 0,
) {
this.chunkID = chunkID
this.checksum = checksum
this.offset = offset
this.compressedLength = compressedLength
this.uncompressedLength = uncompressedLength
}

constructor(chunkData: ChunkData) {
chunkID = chunkData.chunkID
checksum = chunkData.checksum
offset = chunkData.offset
compressedLength = chunkData.compressedLength
uncompressedLength = chunkData.uncompressedLength
}
}
package `in`.dragonbra.javasteam.types

/**
* Represents a single chunk within a file.
*
* @constructor Initializes a new instance of the [ChunkData] class.
* @constructor Initializes a new instance of the [ChunkData] class with specified values.
*
* @param chunkID Gets or sets the SHA-1 hash chunk id.
* @param checksum Gets or sets the expected Adler32 checksum of this chunk.
* @param offset Gets or sets the chunk offset.
* @param compressedLength Gets or sets the compressed length of this chunk.
* @param uncompressedLength Gets or sets the decompressed length of this chunk.
*/
@Suppress("ArrayInDataClass")
data class ChunkData(
var chunkID: ByteArray? = null,
var checksum: Int = 0,
var offset: Long = 0,
var compressedLength: Int = 0,
var uncompressedLength: Int = 0,
)
Loading
Loading