some cleanup
This commit is contained in:
parent
41934c32cf
commit
be20e2b17a
@ -26,6 +26,8 @@ import net.szum123321.textile_backup.core.Utilities;
|
||||
import net.szum123321.textile_backup.core.restore.AwaitThread;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@ -36,12 +38,37 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
public class Globals {
|
||||
public static final Globals INSTANCE = new Globals();
|
||||
private static final TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME);
|
||||
public static final DateTimeFormatter defaultDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss");
|
||||
public static final Supplier<Hash> CHECKSUM_SUPPLIER = BalticHash::new;
|
||||
public static final Supplier<Hash> CHECKSUM_SUPPLIER = BalticHash::new;/*() -> new Hash() {
|
||||
private final CRC32 crc = new CRC32();
|
||||
|
||||
@Override
|
||||
public void update ( int b){
|
||||
crc.update(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update ( long b) {
|
||||
ByteBuffer v = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
|
||||
v.putLong(b);
|
||||
crc.update(v.array());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update ( byte[] b, int off, int len){
|
||||
crc.update(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getValue () {
|
||||
return crc.getValue();
|
||||
}
|
||||
};*/
|
||||
|
||||
private ExecutorService executorService = null;//TODO: AAAAAAAAAAAAAAA MEMORY LEAK!!!!!!!!!
|
||||
public final AtomicBoolean globalShutdownBackupFlag = new AtomicBoolean(true);
|
||||
|
@ -18,14 +18,12 @@
|
||||
|
||||
package net.szum123321.textile_backup.core.create;
|
||||
|
||||
import org.spongepowered.include.com.google.common.collect.Maps;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BrokenFileHandler {
|
||||
private final HashMap<Path, Exception> store = Maps.newHashMap();
|
||||
private final Map<Path, Exception> store = new HashMap<>();
|
||||
public void handle(Path file, Exception e) { store.put(file, e); }
|
||||
|
||||
public boolean valid() { return store.isEmpty(); }
|
||||
|
@ -21,7 +21,6 @@ import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public record ExecutableBackup(@NotNull MinecraftServer server,
|
||||
ServerCommandSource commandSource,
|
||||
@ -64,7 +63,7 @@ public record ExecutableBackup(@NotNull MinecraftServer server,
|
||||
log.info(builder.toString());
|
||||
}
|
||||
@Override
|
||||
public Void call() throws IOException, ExecutionException, InterruptedException {
|
||||
public Void call() throws Exception {
|
||||
if (save) { //save the world
|
||||
log.sendInfoAL(this, "Saving server...");
|
||||
server.saveAll(true, true, false);
|
||||
@ -119,7 +118,7 @@ public record ExecutableBackup(@NotNull MinecraftServer server,
|
||||
|
||||
} catch (Throwable e) {
|
||||
//ExecutorService swallows exception, so I need to catch everything
|
||||
log.error("An exception occurred when trying to create new backup file!", e);
|
||||
log.error("An exception occurred when trying to create a new backup file!", e);
|
||||
|
||||
if (ConfigHelper.INSTANCE.get().integrityVerificationMode.isStrict()) {
|
||||
try {
|
||||
|
@ -20,7 +20,7 @@ package net.szum123321.textile_backup.core.digest;
|
||||
|
||||
public interface Hash {
|
||||
|
||||
void update(int b) ;
|
||||
void update(int b);
|
||||
|
||||
void update(long b);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user