diff -r 21a6c17f4e3e -r 629f61203db1 src/VersionDictionary.cpp --- a/src/VersionDictionary.cpp Mon Sep 28 23:39:08 2009 -0700 +++ b/src/VersionDictionary.cpp Tue Sep 29 15:46:42 2009 -0700 @@ -12,13 +12,12 @@ #include "Index.h" #include "File.h" #include "Chunk.h" +#include #include #include -#include +#include #include -# define UINT32_MAX (4294967295U) - namespace Mooseyard { @@ -153,9 +152,8 @@ // Verify Indexes: for (int i=0; i<256; i++) { - if (_indexPositions[i] > 0) - if (_indexPositions[i] < _previousTrailerPosition || _indexPositions[i] >= _trailerPosition) - throw File::Error("Bad VersionDictionary trailer (illegal index position)"); + if (_indexPositions[i] >= _trailerPosition) + throw File::Error("Bad VersionDictionary trailer (illegal index position)"); const Index *index = _index(i); if (index) index->validate(); @@ -289,10 +287,13 @@ dstFile->flushDisk(); // Write the trailer: + FilePosition previousTrailerPosition = 0; + if (dstFile==srcFile) + previousTrailerPosition = baseDict->_trailerPosition; FilePosition newTrailerPosition = pos; VersionDictionary::Trailer trailer(newCount, newIndexPositions, - baseDict->_trailerPosition, + previousTrailerPosition, baseDict->generation() + 1); pos += dstFile->write(trailer); @@ -312,10 +313,7 @@ } } - -#pragma mark - -#pragma mark TESTING-ONLY: - + VersionDictionary* VersionDictionary::_appendAndOpen (const Dictionary *addDict, File *dstFile, bool replace) const @@ -326,6 +324,10 @@ return nextVersion; } + +#pragma mark - +#pragma mark TESTING-ONLY: + VersionDictionary* VersionDictionary::create (File *file, const Dictionary *srcDict) { return VersionDictionary(file)._appendAndOpen(srcDict, file, true); }