@@ -33,8 +33,7 @@ +(void)setupDBClientsManager{
33
33
}
34
34
}
35
35
36
- - (instancetype )init
37
- {
36
+ - (instancetype )init {
38
37
self = [super init ];
39
38
if (self) {
40
39
retryCount = 0 ;
@@ -230,7 +229,7 @@ -(void)handleAfterUniqueJsonMetaDataLoaded{
230
229
else if (error){
231
230
if (self.uploadRecord ) {
232
231
self.errorBlock (error.nsError , NO );
233
- [DBErrorHandler handleNetworkErrorWith: error];
232
+ [DBErrorHandler handleNetworkErrorWith: error abErrorMessage: @" Unable to fetch app records from Dropbox. " ];
234
233
}
235
234
// create new appinfo.json
236
235
[self handleAfterUniqueJsonMetaDataLoaded ];
@@ -412,6 +411,9 @@ -(void)dbUploadFile:(NSString *)file to:(NSString *)path mode:(DBFILESWriteMode
412
411
// Track response with result and error
413
412
setResponseBlock: ^(DBFILESFileMetadata * _Nullable response, DBFILESUploadError * _Nullable routeError, DBRequestError * _Nullable error) {
414
413
if (response) {
414
+ // reset retry count
415
+ retryCount = 0 ;
416
+
415
417
[ABLog log: @" Uploaded file metadata = %@ " , response];
416
418
417
419
// AppInfo.json file uploaded and creating shared url
@@ -500,6 +502,9 @@ -(void)uploadNextChunk{
500
502
if (nextChunkToUpload.length < chunkSize) {
501
503
[[[[DBClientsManager authorizedClient ].filesRoutes uploadSessionFinishData: cursor commit: fileCommitInfo inputData: nextChunkToUpload] setResponseBlock: ^(DBFILESFileMetadata * _Nullable result, DBFILESUploadSessionFinishError * _Nullable routeError, DBRequestError * _Nullable networkError) {
502
504
if (result) {
505
+ // reset retry count
506
+ retryCount = 0 ;
507
+
503
508
if (self.dbFileType == DBFileTypeIPA){
504
509
NSString *status = [NSString stringWithFormat: @" Creating Sharable Link for IPA" ];
505
510
[self showStatus: status andShowProgressBar: YES withProgress: -1 ];
@@ -568,7 +573,7 @@ -(void)handleChunkUploadWithLookupError:(DBFILESUploadSessionLookupError * _Null
568
573
} else if (uploadError) {
569
574
[DBErrorHandler handleUploadErrorWith: uploadError];
570
575
} else {
571
- [DBErrorHandler handleNetworkErrorWith: networkError];
576
+ [DBErrorHandler handleNetworkErrorWith: networkError abErrorMessage: nil ];
572
577
}
573
578
}
574
579
}
@@ -606,6 +611,8 @@ -(void)dbGetSharedURLForFile:(NSString *)file{
606
611
607
612
-(void )handleSharedURLError : (DBRequestError *)error forFile : (NSString *)file {
608
613
[[AppDelegate appDelegate ] addSessionLog: [NSString stringWithFormat: @" Create Share Link Error - %@ " ,error]];
614
+
615
+ // Handle clint side SDK error
609
616
if ([error isClientError ]){
610
617
if ([[AppDelegate appDelegate ] isInternetConnected ]){
611
618
[self dbCreateSharedURLForFile: file];
@@ -614,13 +621,27 @@ -(void)handleSharedURLError:(DBRequestError *)error forFile:(NSString *)file{
614
621
[self dbCreateSharedURLForFile: file];
615
622
}];
616
623
}
617
- }else if ([error isHttpError ] && error.statusCode .integerValue == 409 ){
624
+ }
625
+
626
+ // Retry upload if there is any conflict in file upload
627
+ else if ([error isHttpError ] && error.statusCode .integerValue == 409 && retryCount < abOnErrorMaxRetryCount){
618
628
[self dbGetSharedURLForFile: file];
619
- }else {
629
+ }
630
+
631
+ // Handle DB Client and Server error by Retrying Upto 3 times
632
+ else if (retryCount < abOnErrorMaxRetryCount) {
633
+ retryCount++;
634
+ [self dbCreateSharedURLForFile: file];
635
+ [[AppDelegate appDelegate ] addSessionLog: [NSString stringWithFormat: @" Retrying (%ld ) Shared URL due to some error." , (long )retryCount]];
636
+ }
637
+
638
+ // Handle other errors
639
+ else {
620
640
if (self.ciRepoProject ) {
621
641
exit (abExitCodeForUploadFailed);
622
642
}
623
- [DBErrorHandler handleNetworkErrorWith: error];
643
+ retryCount = 0 ;
644
+ [DBErrorHandler handleNetworkErrorWith: error abErrorMessage: @" Unable to create a share URL for the file." ];
624
645
self.errorBlock (nil , YES );
625
646
}
626
647
}
@@ -729,7 +750,7 @@ -(void)deleteBuildFolder{
729
750
} else if (routeError) {
730
751
[DBErrorHandler handleDeleteErrorWith: routeError];
731
752
} else if (networkError) {
732
- [DBErrorHandler handleNetworkErrorWith: networkError];
753
+ [DBErrorHandler handleNetworkErrorWith: networkError abErrorMessage: @" Unable to delete build folder. " ];
733
754
}
734
755
}];
735
756
}
@@ -742,7 +763,7 @@ -(void)deleteBuildRootFolder{
742
763
} else if (routeError) {
743
764
[DBErrorHandler handleDeleteErrorWith: routeError];
744
765
} else if (networkError) {
745
- [DBErrorHandler handleNetworkErrorWith: networkError];
766
+ [DBErrorHandler handleNetworkErrorWith: networkError abErrorMessage: @" Unable to delete file. " ];
746
767
}
747
768
}];
748
769
}
0 commit comments