Don't crash when the same request is filled twice

The OS might request the same file again if we take too much time to
fulfill a request. So in case it's queueing the same one again instead
of bailing out just fail the second one and let the first one finish
properly.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2021-01-25 18:02:42 +01:00 коммит произвёл Kevin Ottens (Rebase PR Action)
Родитель d3c7218ee8
Коммит 21035d48a6
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -307,9 +307,15 @@ void VfsCfApi::fileStatusChanged(const QString &systemFileName, SyncFileStatus f
void VfsCfApi::scheduleHydrationJob(const QString &requestId, const QString &folderPath)
{
Q_ASSERT(std::none_of(std::cbegin(d->hydrationJobs), std::cend(d->hydrationJobs), [=](HydrationJob *job) {
const auto jobAlreadyScheduled = std::any_of(std::cbegin(d->hydrationJobs), std::cend(d->hydrationJobs), [=](HydrationJob *job) {
return job->requestId() == requestId || job->folderPath() == folderPath;
}));
});
if (jobAlreadyScheduled) {
qCWarning(lcCfApi) << "The OS submitted again a hydration request which is already on-going" << requestId << folderPath;
emit hydrationRequestFailed(requestId);
return;
}
if (d->hydrationJobs.isEmpty()) {
emit beginHydrating();