Skip to content

Commit

Permalink
five attemps per transaction plus debug code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Nov 5, 2024
1 parent 7f198e8 commit 78a5a00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 41 deletions.
41 changes: 3 additions & 38 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions core/merginapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

1 comment on commit 78a5a00

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.11.692611 just submitted!

Please sign in to comment.