Made the last scan step (checking for removed files) faster on big libraries
This commit is contained in:
@@ -228,6 +228,32 @@ namespace lms::db
|
||||
.resultValue();
|
||||
}
|
||||
|
||||
void Track::find(Session& session, TrackId& lastRetrievedTrack, std::size_t batchSize, bool& moreResults, const std::function<void(const Track::pointer&)>& func)
|
||||
{
|
||||
session.checkReadTransaction();
|
||||
|
||||
auto collection{ session.getDboSession().find<Track>()
|
||||
.orderBy("id")
|
||||
.where("id > ?").bind(lastRetrievedTrack)
|
||||
.limit(static_cast<int>(batchSize) + 1)
|
||||
.resultList() };
|
||||
|
||||
moreResults = false;
|
||||
|
||||
std::size_t count{};
|
||||
for (auto itResult{ collection.begin() }; itResult != collection.end(); ++itResult)
|
||||
{
|
||||
if (count++ == batchSize)
|
||||
{
|
||||
moreResults = true;
|
||||
break;
|
||||
}
|
||||
|
||||
func(*itResult);
|
||||
lastRetrievedTrack = (*itResult)->getId();
|
||||
}
|
||||
}
|
||||
|
||||
bool Track::exists(Session& session, TrackId id)
|
||||
{
|
||||
session.checkReadTransaction();
|
||||
|
||||
Reference in New Issue
Block a user