Permalink
Browse files

Retry to download checksums file if the first attempt yields a connec…

…tion error (not an HTTP error code)
  • Loading branch information...
1 parent 92333bf commit b1e254364316389d866c648f8c6f1cef4e6beb1e @richard richard committed Oct 15, 2009
Showing with 20 additions and 1 deletion.
  1. +1 −0 Classes/Sync/SyncManager.h
  2. +19 −1 Classes/Sync/SyncManager.m
@@ -33,6 +33,7 @@ typedef enum {
SyncManagerTransferStateUploadingEmptyEditsFile,
SyncManagerTransferStateUploadingLocalChanges,
SyncManagerTransferStateDownloadingChecksums,
+ SyncManagerTransferStateRetryDownloadingChecksums,
SyncManagerTransferStateDownloadingOrgFiles,
} SyncManagerTransferState;
View
@@ -688,6 +688,7 @@ - (void)transferComplete:(TransferContext*)context {
break;
case SyncManagerTransferStateDownloadingChecksums:
+ case SyncManagerTransferStateRetryDownloadingChecksums:
[self processChecksumFile:[context localFile]];
break;
@@ -757,7 +758,24 @@ - (void)transferFailed:(TransferContext*)context {
case SyncManagerTransferStateDownloadingChecksums:
if ([context statusCode] >= 400 && [context statusCode] < 600) {
- // Fetch the Org files, just assume they don't have a checksum file
+ // Fetch the Org files, just assume they don't have a checksum file since the server
+ // gave us an error code answer
+ [self downloadOrgFiles];
+ } else {
+ // If the error code wasn't a 4 or 600, there was likely some connectivity issue
+ // preventing us from downloading the file. Some users reported that simply giving
+ // it another go is good enough, so we'll retry here to see if it helps.
+ DeleteFile([context localFile]);
+ currentState = SyncManagerTransferStateRetryDownloadingChecksums;
+ [self downloadChecksumFile];
+ }
+ break;
+
+ case SyncManagerTransferStateRetryDownloadingChecksums:
+
+ if ([context statusCode] >= 400 && [context statusCode] < 600) {
+ // Fetch the Org files, just assume they don't have a checksum file since the server
+ // gave us an error code answer
[self downloadOrgFiles];
} else {
DeleteFile([context localFile]);

0 comments on commit b1e2543

Please sign in to comment.