import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import org.simantics.databoard.binding.mutable.MutableVariant;
import org.simantics.databoard.serialization.Serializer;
import org.simantics.databoard.util.binary.BinaryMemory;
import org.simantics.databoard.binding.mutable.MutableVariant;
import org.simantics.databoard.serialization.Serializer;
import org.simantics.databoard.util.binary.BinaryMemory;
public int headChangeSetId = 0;
public long transactionId = 1;
public long reservedIds = 3;
public int headChangeSetId = 0;
public long transactionId = 1;
public long reservedIds = 3;
public ArrayList<String> cs = new ArrayList<>();
// public ArrayList<String> ccs = new ArrayList<String>();
public ArrayList<String> cs = new ArrayList<>();
// public ArrayList<String> ccs = new ArrayList<String>();
sha1.update(bytes, digestLength, bytes.length - digestLength);
byte[] newChecksum = sha1.digest();
if (!Arrays.equals(newChecksum, Arrays.copyOfRange(bytes, 0, digestLength))) {
sha1.update(bytes, digestLength, bytes.length - digestLength);
byte[] newChecksum = sha1.digest();
if (!Arrays.equals(newChecksum, Arrays.copyOfRange(bytes, 0, digestLength))) {
"Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
+ Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + f.toAbsolutePath());
}
"Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
+ Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + f.toAbsolutePath());
}
-
- HeadState object = (HeadState) org.simantics.databoard.Files.readFile(new ByteArrayInputStream(bytes, digestLength, bytes.length - digestLength), Bindings.getBindingUnchecked(HeadState.class));
- return object;
-
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes, digestLength, bytes.length - digestLength)) {
+ HeadState object = (HeadState) org.simantics.databoard.Files.readFile(bais, Bindings.getBindingUnchecked(HeadState.class));
+ return object;
+ }
- return new HeadState();
-// throw new InvalidHeadStateException(i);
+ Throwable cause = i.getCause();
+ if(cause instanceof AdapterConstructionException) {
+ HeadState1 old = HeadState1.load(directory);
+ return old.migrate();
+ }
+ throw new InvalidHeadStateException(i);
} catch (NoSuchAlgorithmException e) {
throw new Error("SHA-1 Algorithm not found", e);
} catch (Throwable t) {
} catch (NoSuchAlgorithmException e) {
throw new Error("SHA-1 Algorithm not found", e);
} catch (Throwable t) {
int digestLength = sha1.getDigestLength();
sha1.update(bytes, digestLength, bytes.length - digestLength);
byte[] newChecksum = sha1.digest();
if (!Arrays.equals(newChecksum, Arrays.copyOfRange(bytes, 0, digestLength))) {
int digestLength = sha1.getDigestLength();
sha1.update(bytes, digestLength, bytes.length - digestLength);
byte[] newChecksum = sha1.digest();
if (!Arrays.equals(newChecksum, Arrays.copyOfRange(bytes, 0, digestLength))) {
- throw new InvalidHeadStateException(
- "Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
- + Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + headState.toAbsolutePath());
+ LOGGER.error("Checksum " + Arrays.toString(newChecksum) + " does not match excpected " + Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + headState.toAbsolutePath());
+ return false;