Skip to content

Commit

Permalink
Fixed download cancel bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cobbe committed Sep 27, 2016
1 parent 41c81f7 commit 3d9dca1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion ObjectiveDropboxOfficial.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ObjectiveDropboxOfficial'
s.version = '1.0.10'
s.version = '1.0.11'
s.summary = 'Dropbox Objective C SDK for APIv2'
s.homepage = 'https://dropbox.com/developers/'
s.license = 'MIT'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ brew install carthage

```
# ObjectiveDropboxOfficial
github "https://github.com/dropbox/dropbox-sdk-obj-c" ~> 1.0.10
github "https://github.com/dropbox/dropbox-sdk-obj-c" ~> 1.0.11
```

Then, run the following command to checkout and build the Dropbox Objective-C SDK repository:
Expand Down Expand Up @@ -447,7 +447,7 @@ NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding
NSLog(@"%@\n%@\n", routeError, error);
}
}] progress:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
NSLog(@"%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
}];
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ - (DBError *)getDBError:(NSData *)errorData
httpHeaders:(NSDictionary *)httpHeaders {
DBError *dbxError;

if (statusCode == 200) {
return nil;
}

if (clientError) {
return [[DBError alloc] initAsClientError:clientError];
}

if (statusCode == 200) {
return nil;
}

NSDictionary *deserializedData = [self deserializeHttpData:errorData];

Expand Down Expand Up @@ -308,7 +308,7 @@ - (DBDownloadUrlTask *)response:(NSOperationQueue *)queue
NSString *headerString = [self caseInsensitiveLookup:@"Dropbox-API-Result" dictionary:httpHeaders];
NSData *resultData = headerString ? [headerString dataUsingEncoding:NSUTF8StringEncoding] : nil;

if (!resultData) {
if (clientError || !resultData) {
// error data is in response body (downloaded to output tmp file)
NSData *errorData = location ? [NSData dataWithContentsOfFile:[location path]] : nil;
DBError *dbxError = [self getDBError:errorData
Expand All @@ -322,25 +322,25 @@ - (DBDownloadUrlTask *)response:(NSOperationQueue *)queue
}

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path = [_destination path];
NSString *destinationPath = [_destination path];

if ([fileManager fileExistsAtPath:path]) {
if ([fileManager fileExistsAtPath:destinationPath]) {
NSError *fileMoveError;
if (_overwrite) {
[fileManager removeItemAtPath:[_destination path] error:&fileMoveError];
[fileManager removeItemAtPath:destinationPath error:&fileMoveError];
if (fileMoveError) {
responseBlock(nil, nil, [[DBError alloc] initAsClientError:fileMoveError], _destination);
return;
}
}
[fileManager moveItemAtPath:[location path] toPath:path error:&fileMoveError];
[fileManager moveItemAtPath:[location path] toPath:destinationPath error:&fileMoveError];
if (fileMoveError) {
responseBlock(nil, nil, [[DBError alloc] initAsClientError:fileMoveError], _destination);
return;
}
} else {
NSError *fileMoveError;
[fileManager moveItemAtPath:[location path] toPath:path error:&fileMoveError];
[fileManager moveItemAtPath:[location path] toPath:destinationPath error:&fileMoveError];
if (fileMoveError) {
responseBlock(nil, nil, [[DBError alloc] initAsClientError:fileMoveError], _destination);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "DBTasks.h"
#import "DBTransportClient.h"

static NSString const *const kVersion = @"1.0.10";
static NSString const *const kVersion = @"1.0.11";
static NSString const *const kDefaultUserAgentPrefix = @"OfficialDropboxObjCSDKv2";
static NSString const *const kBackgroundSessionId = @"com.dropbox.dropbox_sdk_obj_c_background";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,25 @@ - (IBAction)linkBrowserButtonPressed:(id)sender {
}

- (IBAction)runTestsButtonPressed:(id)sender {
DropboxClient *client = [DropboxClientsManager authorizedClient];
[[client.filesRoutes listFolder:@""]
response:[NSOperationQueue new] response:^(DBFILESListFolderResult *result, DBFILESListFolderError *routeError, DBError *error) {
if (result) {
NSLog(@"%@", [NSThread currentThread]);
NSLog(@"%@", [NSThread mainThread]);
NSLog(@"%@\n", result);
}
}];
// DropboxTester *tester = [[DropboxTester alloc] initWithTestData:[TestData new]];
//
// void (^unlink)() = ^{
// [TestFormat printAllTestsEnd];
// [DropboxClientsManager unlinkClients];
// [self checkButtons];
// };
//
// switch (appPermission) {
// case FullDropbox:
// [self testAllUserEndpoints:tester nextTest:unlink asMember:NO];
// break;
// case TeamMemberFileAccess:
// [self testTeamMemberFileAcessActions:unlink];
// break;
// case TeamMemberManagement:
// [self testTeamMemberManagementActions:unlink];
// break;
// }
DropboxTester *tester = [[DropboxTester alloc] initWithTestData:[TestData new]];

void (^unlink)() = ^{
[TestFormat printAllTestsEnd];
[DropboxClientsManager unlinkClients];
[self checkButtons];
};

switch (appPermission) {
case FullDropbox:
[self testAllUserEndpoints:tester nextTest:unlink asMember:NO];
break;
case TeamMemberFileAccess:
[self testTeamMemberFileAcessActions:unlink];
break;
case TeamMemberManagement:
[self testTeamMemberManagementActions:unlink];
break;
}
}

- (IBAction)unlinkButtonPressed:(id)sender {
Expand Down

0 comments on commit 3d9dca1

Please sign in to comment.