From 032af80d4d7b0ed774d32ae4b1fb71bd0232e4da 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 b723e9585..d486f861d 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -719,13 +719,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)