Skip to content

Commit 38c13fe

Browse files
Merge pull request #196 from vineetchoudhary/develop
Updated Network Errors + Automatic retry option if Create Shared URL failed
2 parents 82912fd + 7b17148 commit 38c13fe

File tree

1,435 files changed

+144155
-58501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,435 files changed

+144155
-58501
lines changed

AppBox.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@
16791679
LD_DYLIB_INSTALL_NAME = "";
16801680
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
16811681
MACOSX_DEPLOYMENT_TARGET = 10.11;
1682+
MARKETING_VERSION = 2.9.1;
16821683
PRODUCT_BUNDLE_IDENTIFIER = com.developerinsider.AppBox;
16831684
PRODUCT_NAME = "$(TARGET_NAME)";
16841685
USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)";
@@ -1722,6 +1723,7 @@
17221723
LD_DYLIB_INSTALL_NAME = "";
17231724
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
17241725
MACOSX_DEPLOYMENT_TARGET = 10.11;
1726+
MARKETING_VERSION = 2.9.1;
17251727
PRODUCT_BUNDLE_IDENTIFIER = com.developerinsider.AppBox;
17261728
PRODUCT_NAME = "$(TARGET_NAME)";
17271729
USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)";

AppBox.xcodeproj/xcshareddata/xcschemes/AppBox.xcscheme

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1030"
3+
LastUpgradeVersion = "1140"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,8 +36,8 @@
3836
ReferencedContainer = "container:AppBox.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
4543
buildConfiguration = "Debug"
@@ -83,8 +81,6 @@
8381
isEnabled = "NO">
8482
</CommandLineArgument>
8583
</CommandLineArguments>
86-
<AdditionalOptions>
87-
</AdditionalOptions>
8884
</LaunchAction>
8985
<ProfileAction
9086
buildConfiguration = "Release"

AppBox/Common/Common.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ + (NSString*)generateUUID {
2222
+ (NSURL *)getFileDirectoryForFilePath:(NSURL *)filePath{
2323
NSArray *pathComponents = [filePath.relativePath pathComponents];
2424
NSString *fileDirectory = [NSString pathWithComponents:[pathComponents subarrayWithRange:NSMakeRange(0, pathComponents.count - 1)]];
25-
fileDirectory = [fileDirectory stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
25+
fileDirectory = [fileDirectory stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];
2626
return [NSURL URLWithString:fileDirectory];
2727
}
2828

AppBox/Common/DBErrorHandler/DBErrorHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@interface DBErrorHandler : NSObject
1212

13-
+(void)handleNetworkErrorWith:(DBRequestError *)networkError;
13+
+(void)handleNetworkErrorWith:(DBRequestError *)networkError abErrorMessage:(NSString *)abErrorMessage;
1414
+(void)handleDeleteErrorWith:(DBFILESDeleteError *)deleteError;
1515
+(void)handleUploadErrorWith:(DBFILESUploadError *)uploadError;
1616
+(void)handleUploadSessionLookupError:(DBFILESUploadSessionLookupError *)error;

AppBox/Common/DBErrorHandler/DBErrorHandler.m

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,71 @@
1010

1111
@implementation DBErrorHandler
1212

13-
+(void)handleNetworkErrorWith:(DBRequestError *)networkError{
14-
switch (networkError.tag) {
15-
case DBRequestErrorAuth:{
16-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors due to invalid authentication credentials. Please login Again."];
17-
[[NSNotificationCenter defaultCenter] postNotificationName:abDropBoxLoggedOutNotification object:self];
18-
}break;
19-
20-
case DBRequestErrorHttp:{
21-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors produced at the HTTP layer. Please try again."];
22-
}break;
23-
24-
case DBRequestErrorAccess:{
25-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors due to invalid permission to access."];
26-
}break;
27-
28-
case DBRequestErrorClient:{
29-
if (![[AppDelegate appDelegate] isInternetConnected]){
30-
[Common showNoInternetConnectionAvailabeAlert];
31-
} else {
32-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors due to a problem on the client-side of the SDK. Please try again."];
33-
}
34-
}break;
35-
36-
case DBRequestErrorBadInput:{
37-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors due to bad input parameters to an API Operation. Please report the issue."];
38-
}break;
39-
40-
case DBRequestErrorPathRoot:{
41-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors due to invalid authentication credentials."];
42-
}break;
43-
44-
case DBRequestErrorRateLimit:{
45-
[Common showAlertWithTitle:@"Error" andMessage:@"Error caused by rate limiting."];
46-
}break;
47-
48-
case DBRequestErrorInternalServer:{
49-
[Common showAlertWithTitle:@"Error" andMessage:@"Errors due to a problem on Dropbox. Please try again."];
50-
}break;
51-
52-
default:{
53-
[Common showAlertWithTitle:@"Error" andMessage:@"Something goes wrong. Please try again."];
54-
}break;
13+
+(void)handleNetworkErrorWith:(DBRequestError *)networkError abErrorMessage:(NSString *)abErrorMessage {
14+
NSMutableString *errorMessage = [[NSMutableString alloc] init];
15+
if (networkError) {
16+
[errorMessage appendFormat:@"\n\nDropbox Request Error - "];
17+
[errorMessage appendFormat:@"\nError Content - %@", networkError.errorContent];
18+
[errorMessage appendFormat:@"\nStatus Code - %@", networkError.statusCode];
19+
[errorMessage appendFormat:@"\nRequest Id - %@", networkError.requestId];
20+
if (abErrorMessage) {
21+
[errorMessage appendFormat:@"\n\nAppBox Error - %@", abErrorMessage];
22+
}
23+
24+
switch (networkError.tag) {
25+
case DBRequestErrorAuth:{
26+
[errorMessage insertString:@"Errors due to invalid authentication credentials. Please login Again." atIndex:0];
27+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
28+
[[NSNotificationCenter defaultCenter] postNotificationName:abDropBoxLoggedOutNotification object:self];
29+
}break;
30+
31+
case DBRequestErrorHttp:{
32+
[errorMessage insertString:@"Errors produced at the HTTP layer. Please check following details and try again." atIndex:0];
33+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
34+
}break;
35+
36+
case DBRequestErrorAccess:{
37+
[errorMessage insertString:@"Errors due to invalid permission to access." atIndex:0];
38+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
39+
}break;
40+
41+
case DBRequestErrorClient:{
42+
if (![[AppDelegate appDelegate] isInternetConnected]){
43+
[Common showNoInternetConnectionAvailabeAlert];
44+
} else {
45+
[errorMessage insertString:@"Errors due to a problem on the client-side of the SDK. Please check following details and try again." atIndex:0];
46+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
47+
}
48+
}break;
49+
50+
case DBRequestErrorBadInput:{
51+
[errorMessage insertString:@"Errors due to bad input parameters to an API Operation. Please report the issue." atIndex:0];
52+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
53+
}break;
54+
55+
case DBRequestErrorPathRoot:{
56+
[errorMessage insertString:@"Errors due to invalid authentication credentials." atIndex:0];
57+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
58+
}break;
59+
60+
case DBRequestErrorRateLimit:{
61+
[errorMessage insertString:@"Error caused by rate limiting." atIndex:0];
62+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
63+
}break;
64+
65+
case DBRequestErrorInternalServer:{
66+
[errorMessage insertString:@"Errors due to a problem on Dropbox Server. Please try again." atIndex:0];
67+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
68+
}break;
69+
70+
default:{
71+
[errorMessage insertString:@"Something goes wrong. Please try again." atIndex:0];
72+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
73+
}break;
74+
}
75+
} else {
76+
[errorMessage insertString:@"Something goes wrong. Please try again." atIndex:0];
77+
[Common showAlertWithTitle:@"Error" andMessage:errorMessage];
5578
}
5679
}
5780

AppBox/Common/UploadManager/UploadManager.m

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ +(void)setupDBClientsManager{
3333
}
3434
}
3535

36-
- (instancetype)init
37-
{
36+
- (instancetype)init {
3837
self = [super init];
3938
if (self) {
4039
retryCount = 0;
@@ -230,7 +229,7 @@ -(void)handleAfterUniqueJsonMetaDataLoaded{
230229
else if (error){
231230
if (self.uploadRecord) {
232231
self.errorBlock(error.nsError, NO);
233-
[DBErrorHandler handleNetworkErrorWith:error];
232+
[DBErrorHandler handleNetworkErrorWith:error abErrorMessage:@"Unable to fetch app records from Dropbox."];
234233
}
235234
//create new appinfo.json
236235
[self handleAfterUniqueJsonMetaDataLoaded];
@@ -412,6 +411,9 @@ -(void)dbUploadFile:(NSString *)file to:(NSString *)path mode:(DBFILESWriteMode
412411
//Track response with result and error
413412
setResponseBlock:^(DBFILESFileMetadata * _Nullable response, DBFILESUploadError * _Nullable routeError, DBRequestError * _Nullable error) {
414413
if (response) {
414+
//reset retry count
415+
retryCount = 0;
416+
415417
[ABLog log:@"Uploaded file metadata = %@", response];
416418

417419
//AppInfo.json file uploaded and creating shared url
@@ -500,6 +502,9 @@ -(void)uploadNextChunk{
500502
if (nextChunkToUpload.length < chunkSize) {
501503
[[[[DBClientsManager authorizedClient].filesRoutes uploadSessionFinishData:cursor commit:fileCommitInfo inputData:nextChunkToUpload] setResponseBlock:^(DBFILESFileMetadata * _Nullable result, DBFILESUploadSessionFinishError * _Nullable routeError, DBRequestError * _Nullable networkError) {
502504
if (result) {
505+
//reset retry count
506+
retryCount = 0;
507+
503508
if (self.dbFileType == DBFileTypeIPA){
504509
NSString *status = [NSString stringWithFormat:@"Creating Sharable Link for IPA"];
505510
[self showStatus:status andShowProgressBar:YES withProgress:-1];
@@ -568,7 +573,7 @@ -(void)handleChunkUploadWithLookupError:(DBFILESUploadSessionLookupError * _Null
568573
} else if (uploadError) {
569574
[DBErrorHandler handleUploadErrorWith:uploadError];
570575
} else {
571-
[DBErrorHandler handleNetworkErrorWith:networkError];
576+
[DBErrorHandler handleNetworkErrorWith:networkError abErrorMessage:nil];
572577
}
573578
}
574579
}
@@ -606,6 +611,8 @@ -(void)dbGetSharedURLForFile:(NSString *)file{
606611

607612
-(void)handleSharedURLError:(DBRequestError *)error forFile:(NSString *)file{
608613
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Create Share Link Error - %@",error]];
614+
615+
//Handle clint side SDK error
609616
if ([error isClientError]){
610617
if ([[AppDelegate appDelegate] isInternetConnected]){
611618
[self dbCreateSharedURLForFile:file];
@@ -614,13 +621,27 @@ -(void)handleSharedURLError:(DBRequestError *)error forFile:(NSString *)file{
614621
[self dbCreateSharedURLForFile:file];
615622
}];
616623
}
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){
618628
[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 {
620640
if (self.ciRepoProject) {
621641
exit(abExitCodeForUploadFailed);
622642
}
623-
[DBErrorHandler handleNetworkErrorWith:error];
643+
retryCount = 0;
644+
[DBErrorHandler handleNetworkErrorWith:error abErrorMessage:@"Unable to create a share URL for the file."];
624645
self.errorBlock(nil, YES);
625646
}
626647
}
@@ -729,7 +750,7 @@ -(void)deleteBuildFolder{
729750
} else if (routeError) {
730751
[DBErrorHandler handleDeleteErrorWith:routeError];
731752
} else if (networkError) {
732-
[DBErrorHandler handleNetworkErrorWith:networkError];
753+
[DBErrorHandler handleNetworkErrorWith:networkError abErrorMessage:@"Unable to delete build folder."];
733754
}
734755
}];
735756
}
@@ -742,7 +763,7 @@ -(void)deleteBuildRootFolder{
742763
} else if (routeError) {
743764
[DBErrorHandler handleDeleteErrorWith:routeError];
744765
} else if (networkError) {
745-
[DBErrorHandler handleNetworkErrorWith:networkError];
766+
[DBErrorHandler handleNetworkErrorWith:networkError abErrorMessage:@"Unable to delete file."];
746767
}
747768
}];
748769
}

AppBox/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<key>CFBundlePackageType</key>
107107
<string>APPL</string>
108108
<key>CFBundleShortVersionString</key>
109-
<string>2.9.0</string>
109+
<string>$(MARKETING_VERSION)</string>
110110
<key>CFBundleSignature</key>
111111
<string>????</string>
112112
<key>CFBundleURLTypes</key>

AppBox/Model/ProjectModel/XCProject.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ - (void)createBuildRelatedPathsAndIsNew:(BOOL)isNew{
9494

9595
//Build UUID Path
9696
NSString *buildUUIDPath = [_buildDirectory.resourceSpecifier stringByAppendingPathComponent:[NSString stringWithFormat:@"%@-%@",self.name, currentTime]];
97-
NSString* escapedBuildUUIDPath = [buildUUIDPath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
97+
NSString* escapedBuildUUIDPath = [buildUUIDPath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];
9898
_buildUUIDDirectory = [NSURL URLWithString:escapedBuildUUIDPath];
9999
[[NSFileManager defaultManager] createDirectoryAtPath:buildUUIDPath withIntermediateDirectories:NO attributes:nil error:nil];
100100

@@ -104,7 +104,7 @@ - (void)createBuildRelatedPathsAndIsNew:(BOOL)isNew{
104104

105105
//IPA Path
106106
NSString *ipaPath = [_buildUUIDDirectory.resourceSpecifier stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.ipa", self.selectedSchemes]];
107-
_ipaFullPath = [NSURL URLWithString:[ipaPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
107+
_ipaFullPath = [NSURL URLWithString:[ipaPath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]]];
108108

109109
//Export Option Plist
110110
NSString *exportOptionPlistPath = [_buildUUIDDirectory.resourceSpecifier stringByAppendingPathComponent:[NSString stringWithFormat:@"%@-ExportOptions.plist", self.name]];

Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ source 'https://cdn.cocoapods.org/'
33
inhibit_all_warnings!
44

55
target :AppBox do
6-
pod 'ISO8601'
76
pod 'AFNetworking'
87
pod 'SSZipArchive'
98
pod 'CMDQueryStringSerialization'

0 commit comments

Comments
 (0)