From fc8588f835eb79d6af2ad809a98a9ddd773475ee Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Sun, 17 Sep 2023 20:29:26 +0200 Subject: [PATCH] fix computation of timeout for jobs to have proper bounds (min < max) Signed-off-by: Matthieu Gallien --- src/libsync/propagateupload.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index ca08042eeaf20..50eba10f1fa75 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -709,13 +709,14 @@ void PropagateUploadFileCommon::commonErrorHandling(AbstractNetworkJob *job) void PropagateUploadFileCommon::adjustLastJobTimeout(AbstractNetworkJob *job, qint64 fileSize) { constexpr double threeMinutes = 3.0 * 60 * 1000; + constexpr qint64 thirtyMinutes = 30 * 60 * 1000; job->setTimeout(qBound( - job->timeoutMsec(), // Calculate 3 minutes for each gigabyte of data - qRound64(threeMinutes * fileSize / 1e9), + qMin(thirtyMinutes - 1, qRound64(threeMinutes * fileSize / 1e9)), + job->timeoutMsec(), // Maximum of 30 minutes - static_cast(30 * 60 * 1000))); + thirtyMinutes)); } void PropagateUploadFileCommon::slotJobDestroyed(QObject *job)