YYYYEEEEEEEEEEEEEEEEEEe I finally debugged the hash!!!!!
The problem was due to an error in usage o FileTreeHashBuilder during unpacking.
This commit is contained in:
parent
fe9f9f3e0d
commit
b9af3b3777
@ -1,18 +1,18 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
minecraft_version=23w18a
|
||||
yarn_mappings=23w18a+build.5
|
||||
minecraft_version=1.20-pre1
|
||||
yarn_mappings=1.20-pre1+build.2
|
||||
loader_version=0.14.19
|
||||
|
||||
#Fabric api
|
||||
fabric_version=0.80.1+1.20
|
||||
fabric_version=0.80.2+1.20
|
||||
|
||||
#Cloth Config
|
||||
cloth_version=11.0.97
|
||||
|
||||
#ModMenu
|
||||
modmenu_version=6.2.2
|
||||
modmenu_version=7.0.0-beta.2
|
||||
|
||||
databreaker_version=0.2.10
|
||||
|
||||
|
@ -60,11 +60,6 @@ public class TextileBackup implements ModInitializer {
|
||||
|
||||
log.info("Starting Textile Backup {} by Szum123321", Globals.INSTANCE.getCombinedVersionString());
|
||||
|
||||
if(FabricLoader.getInstance().isDevelopmentEnvironment()) {
|
||||
//Run the tests
|
||||
BalticHashTest.run();
|
||||
}
|
||||
|
||||
ConfigHelper.updateInstance(AutoConfig.register(ConfigPOJO.class, JanksonConfigSerializer::new));
|
||||
|
||||
ServerTickEvents.END_SERVER_TICK.register(BackupScheduler::tick);
|
||||
|
@ -115,9 +115,7 @@ public class Utilities {
|
||||
}
|
||||
|
||||
public static boolean isBlacklisted(Path path) {
|
||||
if(isWindows()) { //hotfix!
|
||||
if (path.getFileName().toString().equals("session.lock")) return true;
|
||||
}
|
||||
if (path.getFileName().equals("session.lock")) return true;
|
||||
|
||||
if(path.getFileName().endsWith(CompressionStatus.DATA_FILENAME)) return true;
|
||||
|
||||
|
@ -38,8 +38,8 @@ public class BalticHash implements Hash {
|
||||
protected final ByteBuffer buffer = ByteBuffer.wrap(_byte_buffer).order(ByteOrder.LITTLE_ENDIAN);
|
||||
protected long hashed_data_length = 0;
|
||||
|
||||
public void update(byte b) {
|
||||
buffer.put(b);
|
||||
public void update(int b) {
|
||||
buffer.put((byte)b);
|
||||
hashed_data_length += 1;
|
||||
if (buffer.position() >= buffer_limit) round();
|
||||
}
|
||||
|
@ -36,13 +36,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public class FileTreeHashBuilder {
|
||||
private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME);
|
||||
private final Object lock = new Object();
|
||||
private long hash = 0, filesToProcess, filesTotalSize = 0;
|
||||
private final AtomicBoolean closed = new AtomicBoolean(false);
|
||||
private long hash = 0, filesProcessed = 0, filesTotalSize = 0;
|
||||
|
||||
private final CountDownLatch latch;
|
||||
|
||||
public FileTreeHashBuilder(int filesToProcess) {
|
||||
this.filesToProcess = filesToProcess;
|
||||
latch = new CountDownLatch(filesToProcess);
|
||||
}
|
||||
|
||||
@ -55,23 +53,23 @@ public class FileTreeHashBuilder {
|
||||
|
||||
synchronized (lock) {
|
||||
this.hash ^= newHash;
|
||||
filesToProcess--;
|
||||
filesTotalSize += size;
|
||||
filesProcessed++;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRemaining() { return (int) latch.getCount(); }
|
||||
|
||||
synchronized public long getValue(boolean lock) throws InterruptedException {
|
||||
public long getValue(boolean lock) throws InterruptedException {
|
||||
long leftover = latch.getCount();
|
||||
if(lock) latch.await();
|
||||
else if(leftover != 0) log.warn("Finishing with {} files unprocessed!", leftover);
|
||||
|
||||
var hasher = Globals.CHECKSUM_SUPPLIER.get();
|
||||
|
||||
log.debug("Closing: files: {}, bytes {}, raw hash {}", filesToProcess, filesTotalSize, hash);
|
||||
log.debug("Closing: files: {}, bytes {}, raw hash {}", filesProcessed, filesTotalSize, hash);
|
||||
hasher.update(hash);
|
||||
hasher.update(filesToProcess);
|
||||
hasher.update(filesProcessed);
|
||||
hasher.update(filesTotalSize);
|
||||
|
||||
return hasher.getValue();
|
||||
|
@ -19,9 +19,8 @@
|
||||
package net.szum123321.textile_backup.core.digest;
|
||||
|
||||
public interface Hash {
|
||||
void update(byte b);
|
||||
|
||||
default void update(int b) { update((byte)b); }
|
||||
void update(int b) ;
|
||||
|
||||
void update(long b);
|
||||
|
||||
|
@ -38,8 +38,6 @@ import java.nio.file.Path;
|
||||
* That is what CountDownLatch does
|
||||
*/
|
||||
public class HashingInputStream extends FilterInputStream {
|
||||
private final static TextileLogger log = new TextileLogger(TextileBackup.MOD_NAME);
|
||||
|
||||
private final Path path;
|
||||
private final Hash hasher = Globals.CHECKSUM_SUPPLIER.get();
|
||||
private final FileTreeHashBuilder hashBuilder;
|
||||
|
@ -41,7 +41,7 @@ public class HashingOutputStream extends FilterOutputStream {
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
out.write(b);
|
||||
hasher.update((byte)b);
|
||||
hasher.update(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.0",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.20-alpha.23.18.a",
|
||||
"minecraft": "1.20-beta.1",
|
||||
"cloth-config2": "*",
|
||||
"java": ">=16"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user