diff --git a/core/merginapi.cpp b/core/merginapi.cpp index a25f1eb9f..992339903 100644 --- a/core/merginapi.cpp +++ b/core/merginapi.cpp @@ -266,16 +266,6 @@ void MerginApi::downloadNextItem( const QString &projectFullName ) DownloadQueueItem item = transaction.downloadQueue.takeFirst(); - QString itemInfo = QStringLiteral( "downloadNextItem : DownloadQueueItem(path: %1, size: %2, version: %3, range: %4-%5, diff: %6, temp: %7)" ) - .arg( item.filePath ) - .arg( item.size ) - .arg( item.version ) - .arg( item.rangeFrom ) - .arg( item.rangeTo ) - .arg( item.downloadDiff ) - .arg( item.tempFileName ); - qDebug() << "Processing item:" << itemInfo; - QUrl url( mApiRoot + QStringLiteral( "/v1/project/raw/" ) + projectFullName ); QUrlQuery query; // Handles special chars in a filePath (e.g prevents to convert "+" sign into a space) @@ -432,38 +422,13 @@ void MerginApi::downloadItemReplyFinished( DownloadQueueItem item ) // no more requests to start, but there are pending requests - let's do nothing and wait } } - else if ( item.retryCount < transaction.MAX_RETRY_COUNT && isRetryableNetworkError( r ) ) + else if ( transaction.retryCount < transaction.MAX_RETRY_COUNT && isRetryableNetworkError( r ) ) { - item.retryCount++; - // Put the item back at the front for retry - transaction.downloadQueue.prepend( item ); + transaction.retryCount++; + transaction.downloadQueue.append( item ); CoreUtils::log( "pull " + projectFullName, QStringLiteral( "Retrying download (attempt %1 of 5)" ).arg( transaction.retryCount ) ); - QString itemInfo = QStringLiteral( "DownloadQueueItem ( path: %1, size: %2, version: %3, range: %4-%5, diff: %6, temp: %7 )" ) - .arg( item.filePath ) - .arg( item.size ) - .arg( item.version ) - .arg( item.rangeFrom ) - .arg( item.rangeTo ) - .arg( item.downloadDiff ) - .arg( item.tempFileName ); - // qDebug() << "Retrying item:" << itemInfo; - - qDebug() << "Current queue:"; - for ( const DownloadQueueItem &queueItem : transaction.downloadQueue ) - { - QString queueItemInfo = QStringLiteral( "DownloadQueueItem ( path: %1, size: %2, version: %3, range: %4-%5, diff: %6, temp: %7)" ) - .arg( queueItem.filePath ) - .arg( queueItem.size ) - .arg( queueItem.version ) - .arg( queueItem.rangeFrom ) - .arg( queueItem.rangeTo ) - .arg( queueItem.downloadDiff ) - .arg( queueItem.tempFileName ); - qDebug() << queueItemInfo; - } - downloadNextItem( projectFullName ); transaction.replyPullItems.remove( r ); r->deleteLater(); diff --git a/core/merginapi.h b/core/merginapi.h index e8aa30a1d..81fcd30e8 100644 --- a/core/merginapi.h +++ b/core/merginapi.h @@ -109,7 +109,6 @@ struct DownloadQueueItem qint64 rangeTo = -1; //!< what range of bytes to download (-1 if downloading the whole file) bool downloadDiff = false; //!< whether to download just the diff between the previous version and the current one QString tempFileName; //!< relative filename of the temporary file where the downloaded content will be stored - int retryCount = 0; }; @@ -143,8 +142,6 @@ struct TransactionStatus Pull }; - static const int MAX_RETRY_COUNT = 5; //!< maximum number of retry attempts for failed network requests - qreal totalSize = 0; //!< total size (in bytes) of files to be pushed or pulled qint64 transferedSize = 0; //!< size (in bytes) of amount of data transferred so far QString transactionUUID; //!< only for push. Initially dummy non-empty string, after server confirms a valid UUID, on finish/cancel it is empty @@ -171,6 +168,7 @@ struct TransactionStatus // retry handling int retryCount = 0; //!< current number of retry attempts for failed network requests + static const int MAX_RETRY_COUNT = 5; //!< maximum number of retry attempts for failed network requests QString projectDir; QByteArray projectMetadata; //!< metadata of the new project (not parsed)