Mojira Archive
MC-271516

Time information of files in backups is lost

Steps to reproduce:

  1. Create a backup of a world
  2. 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(); 

 

 

Unresolved

lovexyn0827

2024-05-04, 04:24 AM

2024-07-25, 11:06 AM

6

4

Confirmed

Normal

Platform

Save Data

1.20.6, 24w18a, 1.21 Pre-Release 2, 1.21

-