Skip to content

Commit

Permalink
fix computation of timeout for jobs to have proper bounds (min < max)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
  • Loading branch information
mgallien committed Sep 17, 2023
1 parent 5eb4f4b commit fc8588f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libsync/propagateupload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<qint64>(30 * 60 * 1000)));
thirtyMinutes));
}

void PropagateUploadFileCommon::slotJobDestroyed(QObject *job)
Expand Down

0 comments on commit fc8588f

Please sign in to comment.