-
Bug
-
Resolution: Unresolved
-
None
-
1.20.6, 24w18a, 1.21 Pre-Release 2, 1.21
-
None
-
Confirmed
-
Save Data
-
Normal
-
Platform
Steps to reproduce:
- Create a backup of a world
- Open the backup and find that the last modified times of files inside are absent.
As a result, when replacing the original save with a backup, the time information, which indicates when a given area is touched for the last time and when a player joined the save for the last time, etc., would be lost.
Possible solution
Following is the vanilla implementation to add a file to a backup.
ZipEntry zipEntry = new ZipEntry(string);
zipOutputStream.putNextEntry(zipEntry);
com.google.common.io.Files.asByteSource(path.toFile()).copyTo(zipOutputStream);
zipOutputStream.closeEntry();
The ZipEntry class provides a few methods like setLastModifiedTime() to set the time information of corresponding files, by using them we can easily do it.
ZipEntry zipEntry = new ZipEntry(string); zipEntry.setLastModifiedTime(Files.getLastModifiedTime(path)); // Then set the created & last accessed time... zipOutputStream.putNextEntry(zipEntry); com.google.common.io.Files.asByteSource(path.toFile()).copyTo(zipOutputStream); zipOutputStream.closeEntry();