Permalink
Browse files

Fixed restoring session after Ramus crashed, closed #1

  • Loading branch information...
Vitaliy-Yakovchuk committed Nov 11, 2015
1 parent 15ec475 commit 846fcd1a2b7f87b4e4bc0de51bc4519d80f9aecc
@@ -36,6 +36,12 @@
public class Journal implements Journaled {
public static final RedoCallback TRUE_REDO_CALLBACK = new RedoCallback() {
@Override
public boolean execute(Command command) {
return true;
}
};
protected BinaryAccessFile accessFile;
private static Hashtable<Class<? extends Command>, Integer> commandsTypes;
@@ -164,12 +170,17 @@ public void registerEngine(JournaledEngine engine) {
}
public Command redo() {
return redo(TRUE_REDO_CALLBACK);
}
public Command redo(RedoCallback callback) {
Command command = null;
long index = getPointer();
try {
command = readNext();
IEngine engine = command.getEngine().deligate;
command.redo(engine);
if(callback.execute(command))
command.redo(engine);
JournalEvent event = new JournalEvent(this, command, index);
afterRedo(event);
@@ -469,4 +480,8 @@ public void setLock(boolean lock) {
public long getBranch() {
return branch;
}
public interface RedoCallback {
boolean execute(Command command);
}
}
@@ -706,11 +706,23 @@ protected FileIEngineImpl createFileIEngine(PluginFactory factory)
if (journals.length == 0)
return false;
boolean exist = false;
Journal.RedoCallback redoCallback = new Journal.RedoCallback() {
boolean hadStartUserTransaction;
@Override
public boolean execute(Command command) {
if (command instanceof StartUserTransactionCommand) {
hadStartUserTransaction = true;
}
return hadStartUserTransaction;
}
};
for (Journal journal : journals) {
try {
Command command = null;
while (journal.canRedo()) {
command = journal.redo();
command = journal.redo(redoCallback);
}
if ((journal.getPointer() == 0l)
|| (command instanceof StopUndoPointCommand)) {

0 comments on commit 846fcd1

Please sign in to comment.