formatting
parent
cf3078259b
commit
9ffaff1a2d
|
@ -30,12 +30,12 @@ import java.util.Optional;
|
||||||
|
|
||||||
public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, String version) implements Serializable {
|
public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, String version) implements Serializable {
|
||||||
public static final String DATA_FILENAME = "textile_status.data";
|
public static final String DATA_FILENAME = "textile_status.data";
|
||||||
|
|
||||||
public Optional<String> validate(long hash, RestoreContext ctx) throws RuntimeException {
|
public Optional<String> validate(long hash, RestoreContext ctx) throws RuntimeException {
|
||||||
if(hash != treeHash)
|
if(hash != treeHash)
|
||||||
return Optional.of("Tree Hash mismatch!\n Expected: " + treeHash + ", got: " + hash);
|
return Optional.of("Tree Hash mismatch!\n Expected: " + hex(treeHash) + ", got: " + hex(hash));
|
||||||
|
|
||||||
if(!brokenFiles.isEmpty())
|
if(!brokenFiles.isEmpty()) return Optional.of("Damaged files present! ^");
|
||||||
return Optional.of("Damaged files present! ^");
|
|
||||||
|
|
||||||
if(ctx.restoreableFile().getCreationTime().equals(date))
|
if(ctx.restoreableFile().getCreationTime().equals(date))
|
||||||
return Optional.of(
|
return Optional.of(
|
||||||
|
@ -67,15 +67,16 @@ public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles,
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("{ ");
|
||||||
builder.append("Hash: ")
|
builder.append("Hash: ")
|
||||||
.append(treeHash)
|
.append(hex(treeHash))
|
||||||
.append(", Date: ")
|
.append(", Date: ")
|
||||||
.append(date.format(DateTimeFormatter.ISO_DATE_TIME))
|
.append(date.format(DateTimeFormatter.ISO_DATE_TIME))
|
||||||
.append(", start timestamp: ").append(startTimestamp)
|
.append(", Start timestamp: ").append(startTimestamp)
|
||||||
.append(", finish timestamp: ").append(finishTimestamp)
|
.append(", Finish timestamp: ").append(finishTimestamp)
|
||||||
.append(", Mod Version: ").append(version);
|
.append(", Mod Version: ").append(version);
|
||||||
|
|
||||||
builder.append(", broken files: ");
|
builder.append(", Broken files: ");
|
||||||
if(brokenFiles.isEmpty()) builder.append("[]");
|
if(brokenFiles.isEmpty()) builder.append("[]");
|
||||||
else {
|
else {
|
||||||
builder.append("[\n");
|
builder.append("[\n");
|
||||||
|
@ -90,6 +91,10 @@ public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles,
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.append(" }");
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String hex(long val) { return "0x" + Long.toHexString(val).toUpperCase(); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue