internal static JournalFile GetJournalFile(StorageEnvironment env, long journalNum, IncrementalBackupInfo backupInfo) { var journalFile = env.Journal.Files.FirstOrDefault(x => x.Number == journalNum); // first check journal files currently being in use if (journalFile != null) { journalFile.AddRef(); return(journalFile); } try { using (var pager = env.Options.OpenJournalPager(journalNum)) { long journalSize = Bits.NextPowerOf2(pager.NumberOfAllocatedPages * env.Options.PageSize); journalFile = new JournalFile(env.Options.CreateJournalWriter(journalNum, journalSize), journalNum); journalFile.AddRef(); return(journalFile); } } catch (Exception e) { if (backupInfo.LastBackedUpJournal == -1 && journalNum == 0 && e.Message.StartsWith("No such journal", StringComparison.Ordinal)) { throw new InvalidOperationException("The first incremental backup creation failed because the first journal file " + StorageEnvironmentOptions.JournalName(journalNum) + " was not found. " + "Did you turn on the incremental backup feature after initializing the storage? " + "In order to create backups incrementally the storage must be created with IncrementalBackupEnabled option set to 'true'.", e); } throw; } }
internal static JournalFile GetJournalFile(StorageEnvironment env, long journalNum, IncrementalBackupInfo backupInfo) { var journalFile = env.Journal.Files.FirstOrDefault(x => x.Number == journalNum); // first check journal files currently being in use if (journalFile != null) { journalFile.AddRef(); return journalFile; } try { using (var pager = env.Options.OpenJournalPager(journalNum)) { long journalSize = Utils.NearestPowerOfTwo(pager.NumberOfAllocatedPages * AbstractPager.PageSize); journalFile = new JournalFile(env.Options.CreateJournalWriter(journalNum, journalSize), journalNum); journalFile.AddRef(); return journalFile; } } catch (Exception e) { if (backupInfo.LastBackedUpJournal == -1 && journalNum == 0 && e.Message.StartsWith("No such journal")) { throw new InvalidOperationException("The first incremental backup creation failed because the first journal file " + StorageEnvironmentOptions.JournalName(journalNum) + " was not found. " + "Did you turn on the incremental backup feature after initializing the storage? " + "In order to create backups incrementally the storage must be created with IncrementalBackupEnabled option set to 'true'.", e); } throw; } }