Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
fix bookmark advance (#27)
Browse files Browse the repository at this point in the history
One of the scenarios was not moving the bookmark to the next file

I'm merging this one into dev to get a package to test . Should have correct behaviour based on observations
  • Loading branch information
MiguelAlho authored Oct 9, 2017
1 parent eaa7dd7 commit 146ef48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void MoveBookmarkForward()
{
//move to next file
_currentBookmark = new FileSetPosition(0, fileSet[1]);
_bookmarkProvider.UpdateBookmark(_currentBookmark);
//we can also delete the previously read file since we no longer need it
_fileSystemAdapter.DeleteFile(fileSet[0]);
}
Expand All @@ -145,8 +146,9 @@ public void MoveBookmarkForward()
{
//move to first file within retention limite
_currentBookmark = _retainedFileCountLimit.Value >= fileSet.Length
? new FileSetPosition(0, fileSet[0])
? new FileSetPosition(0, fileSet[1])
: new FileSetPosition(0, fileSet[fileSet.Length - _retainedFileCountLimit.Value]);
_bookmarkProvider.UpdateBookmark(_currentBookmark);

//delete all the old files
foreach (var oldFile in fileSet.Take(fileSet.Length - _retainedFileCountLimit.Value))
Expand All @@ -158,6 +160,7 @@ public void MoveBookmarkForward()
{
//move to the next file and delete the current one
_currentBookmark = new FileSetPosition(0, fileSet[1]);
_bookmarkProvider.UpdateBookmark(_currentBookmark); //set the file bookmark to avoid
_fileSystemAdapter.DeleteFile(fileSet[0]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ IFileSystemAdapter CreateFileSystemAdapter()
public void BookmarkShouldBeAtStartOfNextFile() => Assert.Equal(0, _sut.NextLineStart);

[Fact]
public void BookmarkShouldBeAtNextFile() => Assert.Equal(@"c:\a\file001.json", _sut.File);
public void BookmarkShouldBeAtNextFile() => Assert.Equal(@"c:\a\file002.json", _sut.File);

[Fact]
public void NoFilesShouldHaveBeenDeleted() => Assert.Empty(_deletedFiles);
Expand Down

0 comments on commit 146ef48

Please sign in to comment.