fix computation of timeout for jobs to have proper bounds (min < max)

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2023-09-17 20:29:26 +02:00 committed by Matthieu Gallien
parent 09e60744c2
commit 032af80d4d

View file

@ -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<qint64>(30 * 60 * 1000)));
thirtyMinutes));
}
void PropagateUploadFileCommon::slotJobDestroyed(QObject *job)