Skip to content

Commit

Permalink
fix claim-only backup failing when encountering renamed region files
Browse files Browse the repository at this point in the history
Signed-off-by: Lyfts <127234178+Lyfts@users.noreply.github.com>
  • Loading branch information
Lyfts committed Feb 13, 2025
1 parent 4ae15c0 commit 69172c5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/serverutils/task/backup/ThreadBackup.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ private static Object2ObjectMap<File, ObjectSet<ChunkDimPos>> mapClaimsToRegionF

for (File file : regions) {
int[] coords = getRegionCoords(file);
if (coords == null) continue;
long key = CoordinatePacker.pack(coords[0], 0, coords[1]);
ObjectSet<ChunkDimPos> claims = regionClaims.get(key);
if (claims == null) {
Expand All @@ -250,14 +251,17 @@ private static Object2ObjectMap<File, ObjectSet<ChunkDimPos>> mapClaimsToRegionF
return regionFilesToBackup;
}

private static int[] getRegionCoords(File f) {
String fileName = f.getName();
int firstDot = fileName.indexOf('.');
int secondDot = fileName.indexOf('.', firstDot + 1);
private static int[] getRegionCoords(File file) {
if (!file.getName().endsWith(".mca")) return null;

int x = Integer.parseInt(fileName.substring(firstDot + 1, secondDot));
int z = Integer.parseInt(fileName.substring(secondDot + 1, fileName.lastIndexOf('.')));
return new int[] { x, z };
String[] parts = file.getName().split("\\.");
try {
int x = Integer.parseInt(parts[1]);
int z = Integer.parseInt(parts[2]);
return new int[] { x, z };
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
return null;
}
}

private static String getDoneTime(long l) {
Expand Down

0 comments on commit 69172c5

Please # to comment.