Skip to content

Commit 2d138c1

Browse files
committed
fix fa zip handling
1 parent 2b87522 commit 2d138c1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

apps/faf-legacy-deployment/scripts/CoopDeployer.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,23 @@ class Patcher(
379379
require(Files.isRegularFile(path)) { "Path $path is not a regular file" }
380380

381381
val archiveName = base.relativize(path).toString().replace("\\", "/")
382-
val entry = ZipEntry(archiveName)
383-
// fix timestamp for determinism (not strictly necessary)
384-
entry.time = 315532800000L
382+
383+
384+
// Read file fully (FA requires sizes & CRC up front otherwise can't read the zip file)
385+
val bytes = Files.readAllBytes(path)
386+
val crc = java.util.zip.CRC32().apply { update(bytes) }
387+
388+
val entry = ZipEntry(archiveName).apply {
389+
method = ZipEntry.DEFLATED
390+
size = bytes.size.toLong()
391+
compressedSize = -1 // let deflater handle, still no descriptor
392+
this.crc = crc.value
393+
// fix timestamp for determinism (not strictly necessary)
394+
time = 315532800000L // 1980-01-01
395+
}
396+
385397
this.putNextEntry(entry)
386-
Files.newInputStream(path).use { inp -> inp.copyTo(this) }
398+
this.write(bytes)
387399
this.closeEntry()
388400
}
389401

0 commit comments

Comments
 (0)