Solutions zip: use real file/submission timestamps instead of epoch (fixes bogus years)
This commit is contained in:
@@ -43,16 +43,18 @@ class SubmissionStorage(
|
||||
return StoredSubmission(dir, names)
|
||||
}
|
||||
|
||||
/** Собирает zip из сохранённых файлов сдачи. */
|
||||
/** Собирает zip из сохранённых файлов сдачи, сохраняя реальное время изменения файлов. */
|
||||
fun zipOf(storedDir: Path): ByteArray {
|
||||
val out = ByteArrayOutputStream()
|
||||
ZipOutputStream(out).use { zos ->
|
||||
Files.list(storedDir).forEach { file ->
|
||||
ZipEntry(file.fileName.toString()).also { entry ->
|
||||
entry.time = 0
|
||||
zos.putNextEntry(entry)
|
||||
Files.copy(file, zos)
|
||||
zos.closeEntry()
|
||||
Files.list(storedDir).use { stream ->
|
||||
stream.forEach { file ->
|
||||
ZipEntry(file.fileName.toString()).also { entry ->
|
||||
entry.time = Files.getLastModifiedTime(file).toMillis()
|
||||
zos.putNextEntry(entry)
|
||||
Files.copy(file, zos)
|
||||
zos.closeEntry()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user