Improved logic in new head state creation. Earlier any IOException during the reading of head state was interpreted as empty DB. This might cause unwanted DB reset. It's better to identify need for empty head state based on main state head directory. Switched AcornDatabase.start logic back to using RandomAccessFile for touching the db/lock file. Using RandomAccessFile instead of FileSystemProvider.newFileChannel in Windows better prevents any other process from removing the lock file. The newFileChannel version did not prevent the user from initially running 'del lock' to remove the file - although the file will be recreated quickly by the system. Also AcornDatabase.start now re-throws ProCoreException if opening/locking the lock-file fails with IOException to prevent the system from attempting to start up without a proper database to work with. Previously the system just logged the start-up problem and continued. refs #7124 Change-Id: I850b47d8f692e3d1b8ce177b9269540edc4dc272
Fixed bad logical bug from Acorn's MainState.load rollback The major bug was the logical not in MainState.load rollback which caused the database revisioning to be started from 0 when the database was *not* empty. It should have been the other way around. Also cleaned up the database head.state validation code by not using exceptions for flow control in validating head.state files. refs #7124 Change-Id: I7cd57fa73d39a637c71159df63566aed5063fc40
Improved Acorn database rollback logic. MainState will no longer destroy the entire database if the user removes directories but forgets to remove the main.state file. The information stored in main.state is now regarded as cached information only and if it seems invalid or cannot be read, the same normal rollback logic will be performed every time. Another enhancement is that rollback will now automatically store the revisions deleted by the rollback procedure in timestamped <workspace>/db/recovery/yyyy-M-d_HH-mm-ss/ folders for later inspection and debugging. Previously the code just deleted all the extra revisions. Manually removing the recovery-folder is always a safe operation to perform. Also fixed a bug in databoard Files class readFile methods that take a File as argument. Previously all the functions constructed a BinaryFile using the default mode which is "rw". This unintentionally made the readFile methods create an empty file if the file did not exist. All such methods have been changed to use mode "r". refs #7124 Change-Id: I3ac04d2e33151b33f4982cf7a2edce7ddb896e11
Fixed acorn db main.state loading rollback reporting. The previous implementation caused main.state loading to always report the database as requiring rollback which caused the system to always delete all indexes on program startup. refs #6709 Change-Id: Id3d90436c1960faa3ac5ebbc82e817b673934f53
Acorn: Fix WriteRunnable.runReally() and other fixes Lets hope this crlf thing is over after this refs #6709 Change-Id: I4e69d8eebf790c2bf4352c1bc8130ba62f126d2f
Sharing org.simantics.acorn for everyone to use Change-Id: I3e110dd01c31dd0e0885887cfa66e42c3849bc2e