mirror of
https://github.com/kiwix/libkiwix.git
synced 2026-10-24 09:59:24 -04:00
Library::removeBookById() updates the revision
This commit is contained in:
1 parent
9fd1423100
commit
ce8b2bf9d9
3 files changed
+13
-3
No files matched your search
+2
-2
@@ -332,8 +332,8 @@ class Library
|
||||
/**
|
||||
* Return the current revision of the library.
|
||||
*
|
||||
* The revision of the library is updated (incremented by one) only by
|
||||
* the addBook() operation.
|
||||
* The revision of the library is updated (incremented by one) by
|
||||
* the addBook() and removeBookById() operations.
|
||||
*
|
||||
* @return Current revision of the library.
|
||||
*/
|
||||
|
||||
+5
-1
@@ -221,7 +221,11 @@ bool Library::removeBookById(const std::string& id)
|
||||
// Having a too big cache is not a problem here (or it would have been before)
|
||||
// (And setMaxSize doesn't actually reduce the cache size, extra cached items
|
||||
// will be removed in put or getOrPut).
|
||||
return mp_impl->m_books.erase(id) == 1;
|
||||
const bool bookWasRemoved = mp_impl->m_books.erase(id) == 1;
|
||||
if ( bookWasRemoved ) {
|
||||
++mp_impl->m_revision;
|
||||
}
|
||||
return bookWasRemoved;
|
||||
}
|
||||
|
||||
Library::Revision Library::getRevision() const
|
||||
|
||||
@@ -801,8 +801,14 @@ TEST_F(LibraryTest, removeBooksNotUpdatedSince)
|
||||
lib.addBook(lib.getBookByIdThreadSafe(id));
|
||||
}
|
||||
|
||||
EXPECT_GT(lib.getRevision(), rev);
|
||||
|
||||
const uint64_t rev2 = lib.getRevision();
|
||||
|
||||
EXPECT_EQ(9u, lib.removeBooksNotUpdatedSince(rev));
|
||||
|
||||
EXPECT_GT(lib.getRevision(), rev2);
|
||||
|
||||
EXPECT_FILTER_RESULTS(kiwix::Filter(),
|
||||
"Islam Stack Exchange",
|
||||
"Movies & TV Stack Exchange",
|
||||
|
||||
Reference in new issue
Block a user