From: Kevin Ottens Date: Mon, 25 Jan 2021 17:02:42 +0000 (+0100) Subject: Don't crash when the same request is filled twice X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~400^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=21035d48a69a7b14ea4e8c0ff99e1b3e5c94e5bf;p=nextcloud-desktop.git 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 --- diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index 7a5da1e0e..be0eb5f23 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -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();