/// <exception cref="System.IO.IOException"></exception> protected virtual string OldDatabaseFilePath() { string oldFile = IOServices.BuildTempPath("old_db.db4o"); File4.Copy(SourceFile(), oldFile); return(oldFile); }
public void Run() { saveAsBin.Sync(); saveAsBin.Close(); try { File4.Copy(oldUri, newUri); } catch (Exception e) { this._enclosing.ReopenOldConfiguration(saveAsBin, oldConfiguration, newUri, e); } BinConfiguration newConfiguration = this._enclosing.PointToNewUri(oldConfiguration , newUri); try { IBin newBin = this._enclosing._storage.Open(newConfiguration); saveAsBin.DelegateTo(newBin); this._enclosing._binRecords.Remove(oldUri); this._enclosing._binRecords.Put(newUri, new SaveAsStorage.BinRecord(newConfiguration , saveAsBin)); } catch (Exception e) { this._enclosing.ReopenOldConfiguration(saveAsBin, oldConfiguration, newUri, e); } }
/// <exception cref="System.IO.IOException"></exception> public virtual void Test() { var originalFilePath = OriginalFilePath(); var dbFilePath = DbFilePath(); if (!File.Exists(originalFilePath)) { TestPlatform.EmitWarning(originalFilePath + " does not exist. Can not run " + GetType ().FullName); return; } File4.Copy(originalFilePath, dbFilePath); Db4oFactory.Configure().AllowVersionUpdates(true); Db4oFactory.Configure().ExceptionsOnNotStorable(false); var oc = Db4oFactory.OpenFile(dbFilePath); try { Assert.IsNotNull(oc); } finally { oc.Close(); Db4oFactory.Configure().ExceptionsOnNotStorable(true); Db4oFactory.Configure().AllowVersionUpdates(false); } }
/// <exception cref="System.IO.IOException"></exception> private void CreateFile(IConfiguration config, string fileName) { IObjectContainer oc = Db4oFactory.OpenFile(config, fileName); try { Populate(oc); } finally { oc.Close(); } File4.Copy(fileName, fileName + "0"); }
/// <exception cref="System.IO.IOException"></exception> public virtual int WriteVersions(string file, bool writeTrash) { var count = 0; var rcount = 0; var lastFileName = file + "0"; var rightFileName = file + "R"; File4.Copy(lastFileName, rightFileName); var syncIter = _writes.GetEnumerator(); while (syncIter.MoveNext()) { rcount++; var writesBetweenSync = (Collection4)syncIter.Current; var rightRaf = new RandomAccessFile(rightFileName, "rw"); var singleForwardIter = writesBetweenSync.GetEnumerator(); while (singleForwardIter.MoveNext()) { var csw = (CrashSimulatingWrite)singleForwardIter.Current; csw.Write(rightFileName, rightRaf, false); } rightRaf.Close(); var singleBackwardIter = writesBetweenSync.GetEnumerator(); while (singleBackwardIter.MoveNext()) { count++; var csw = (CrashSimulatingWrite)singleBackwardIter.Current; var currentFileName = file + "W" + count; File4.Copy(lastFileName, currentFileName); var raf = new RandomAccessFile(currentFileName, "rw"); csw.Write(currentFileName, raf, writeTrash); raf.Close(); lastFileName = currentFileName; } File4.Copy(rightFileName, rightFileName + rcount); lastFileName = rightFileName; } return(count); }
/// <exception cref="System.IO.IOException"></exception> private void PrepareClientServerTest(string fileName) { File4.Copy(fileName, ClientServerFileName(fileName)); }