Permalink
Browse files

Merge pull request #132 from chuckbjones/130-fix-crash-on-sync-with-m…

…issing-file-rc2

Add DropboxSDK framework to test target
  • Loading branch information...
2 parents 45c2405 + 83147ec commit 61f09719563b076bf1a10341791ad1fe1cc2c787 @ginatrapani committed Mar 26, 2012
@@ -63,11 +63,16 @@ - (id) initWithTarget:(id)aTarget onComplete:(SEL)selector {
}
- (DBRestClient*)restClient {
- if (restClient == nil) {
- restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
- restClient.delegate = self;
- }
- return restClient;
+ if (restClient == nil) {
+ restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
+ restClient.delegate = self;
+ }
+ return restClient;
+}
+
+- (void) reportCompletionWithStatus:(DropboxFileStatus)aStatus {
+ status = aStatus;
+ [target performSelectorOnMainThread:onComplete withObject:self waitUntilDone:NO];
}
- (void) loadNextFile {
@@ -82,8 +87,7 @@ - (void) loadNextFile {
}
} else {
// we're done!
- status = dbSuccess;
- [target performSelector:onComplete withObject:self];
+ [self reportCompletionWithStatus:dbSuccess];
}
}
@@ -121,8 +125,8 @@ - (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata {
if ([metadata.rev isEqualToString:file.originalRev]) {
// don't bother downloading if the rev is the same
file.status = dbNotChanged;
- } else if (metadata.isDeleted) {
- file.status = dbNotFound;
+ } else if (metadata.isDeleted) {
+ file.status = dbNotFound;
} else {
file.status = dbFound;
}
@@ -156,12 +160,11 @@ - (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)theEr
file.status = dbError;
file.error = theError;
- status = dbError;
[error release];
error = [theError retain];
// don't bother downloading any more files after the first error
- [target performSelector:onComplete withObject:self];
+ [self reportCompletionWithStatus:dbError];
}
- (void) dealloc {
@@ -65,13 +65,18 @@ - (id) initWithTarget:(id)aTarget onComplete:(SEL)selector {
}
- (DBRestClient*)restClient {
- if (restClient == nil) {
- restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
- restClient.delegate = self;
- }
- return restClient;
+ if (restClient == nil) {
+ restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
+ restClient.delegate = self;
+ }
+ return restClient;
+}
+
+- (void) reportCompletionWithStatus:(DropboxFileStatus)aStatus {
+ status = aStatus;
+ [target performSelectorOnMainThread:onComplete withObject:self waitUntilDone:NO];
}
-
+
- (void) uploadNextFile {
if (++curFile < files.count) {
DropboxFile *file = [files objectAtIndex:curFile];
@@ -85,8 +90,7 @@ - (void) uploadNextFile {
}
} else {
// we're done!
- status = dbSuccess;
- [target performSelector:onComplete withObject:self];
+ [self reportCompletionWithStatus:dbSuccess];
}
}
@@ -119,26 +123,24 @@ - (void) pushFiles:(NSArray*)dropboxFiles overwrite:(BOOL)doOverwrite {
- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata {
DropboxFile *file = [files objectAtIndex:curFile];
- if (metadata.isDeleted) {
- // if the file does not exist, we can upload it with a nil parentrev
- file.loadedMetadata = nil;
- file.status = dbNotFound;
- } else {
- // save off the returned metadata
- file.loadedMetadata = metadata;
-
- if (!overwrite && ![metadata.rev isEqualToString:file.originalRev]) {
- // Conflict! Stop everything and return to caller
- file.status = dbConflict;
- status = dbConflict;
- [target performSelector:onComplete withObject:self];
-
- return;
- }
-
- file.status = dbFound;
- }
-
+ if (metadata.isDeleted) {
+ // if the file does not exist, we can upload it with a nil parentrev
+ file.loadedMetadata = nil;
+ file.status = dbNotFound;
+ } else {
+ // save off the returned metadata
+ file.loadedMetadata = metadata;
+
+ if (!overwrite && ![metadata.rev isEqualToString:file.originalRev]) {
+ // Conflict! Stop everything and return to caller
+ file.status = dbConflict;
+ [self reportCompletionWithStatus:dbConflict];
+ return;
+ }
+
+ file.status = dbFound;
+ }
+
// get the next metadata
[self loadNextMetadata];
}
@@ -165,8 +167,7 @@ - (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath from:(
// If the uploaded remote path does not match our expected remotePath,
// then a conflict occurred and we should announce the conflict to the user.
file.status = dbConflict;
- status = dbConflict;
- [target performSelector:onComplete withObject:self];
+ [self reportCompletionWithStatus:dbConflict];
return;
}
@@ -181,12 +182,11 @@ - (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)the
file.status = dbError;
file.error = theError;
- status = dbError;
[error release];
error = [theError retain];
// don't bother uploading any more files after the first error
- [target performSelector:onComplete withObject:self];
+ [self reportCompletionWithStatus:dbError];
}
- (void) dealloc {
Binary file not shown.
@@ -10,7 +10,6 @@
#import "DBQuota.h"
@interface DBAccountInfo : NSObject <NSCoding> {
- NSString* email;
NSString* country;
NSString* displayName;
DBQuota* quota;
@@ -20,7 +19,6 @@
- (id)initWithDictionary:(NSDictionary*)dict;
-@property (nonatomic, readonly) NSString* email;
@property (nonatomic, readonly) NSString* country;
@property (nonatomic, readonly) NSString* displayName;
@property (nonatomic, readonly) DBQuota* quota;
@@ -28,19 +28,19 @@
*/
#import <Foundation/Foundation.h>
-#import "SBJsonParser.h"
-#import "SBJsonWriter.h"
+#import "DBJsonParser.h"
+#import "DBJsonWriter.h"
/**
- @brief Facade for SBJsonWriter/SBJsonParser.
+ @brief Facade for DBJsonWriter/DBJsonParser.
- Requests are forwarded to instances of SBJsonWriter and SBJsonParser.
+ Requests are forwarded to instances of DBJsonWriter and DBJsonParser.
*/
-@interface SBJSON : SBJsonBase <SBJsonParser, SBJsonWriter> {
+@interface DBJSON : DBJsonBase <DBJsonParser, DBJsonWriter> {
@private
- SBJsonParser *jsonParser;
- SBJsonWriter *jsonWriter;
+ DBJsonParser *jsonParser;
+ DBJsonWriter *jsonWriter;
}
@@ -29,7 +29,7 @@
#import <Foundation/Foundation.h>
-extern NSString * SBJSONErrorDomain;
+extern NSString * DBJSONErrorDomain;
enum {
@@ -52,7 +52,7 @@ enum {
This class contains the common error-handling code and option between the parser/writer.
*/
-@interface SBJsonBase : NSObject {
+@interface DBJsonBase : NSObject {
NSMutableArray *errorTrace;
@protected
@@ -28,14 +28,14 @@
*/
#import <Foundation/Foundation.h>
-#import "SBJsonBase.h"
+#import "DBJsonBase.h"
/**
@brief Options for the parser class.
- This exists so the SBJSON facade can implement the options in the parser without having to re-declare them.
+ This exists so the DBJSON facade can implement the options in the parser without having to re-declare them.
*/
-@protocol SBJsonParser
+@protocol DBJsonParser
/**
@brief Return the object represented by the given string.
@@ -71,7 +71,7 @@
as we can thus avoid any loss of precision. (JSON allows ridiculously large numbers.)
*/
-@interface SBJsonParser : SBJsonBase <SBJsonParser> {
+@interface DBJsonParser : DBJsonBase <DBJsonParser> {
@private
const char *c;
@@ -80,7 +80,7 @@
@end
// don't use - exists for backwards compatibility with 2.1.x only. Will be removed in 2.3.
-@interface SBJsonParser (Private)
+@interface DBJsonParser (Private)
- (id)fragmentWithString:(id)repr;
@end
@@ -28,14 +28,14 @@
*/
#import <Foundation/Foundation.h>
-#import "SBJsonBase.h"
+#import "DBJsonBase.h"
/**
@brief Options for the writer class.
- This exists so the SBJSON facade can implement the options in the writer without having to re-declare them.
+ This exists so the DBJSON facade can implement the options in the writer without having to re-declare them.
*/
-@protocol SBJsonWriter
+@protocol DBJsonWriter
/**
@brief Whether we are generating human-readable (multiline) JSON.
@@ -91,7 +91,7 @@
way you would expect.
*/
-@interface SBJsonWriter : SBJsonBase <SBJsonWriter> {
+@interface DBJsonWriter : DBJsonBase <DBJsonWriter> {
@private
BOOL sortKeys, humanReadable;
@@ -100,7 +100,7 @@
@end
// don't use - exists for backwards compatibility. Will be removed in 2.3.
-@interface SBJsonWriter (Private)
+@interface DBJsonWriter (Private)
- (NSString*)stringWithFragment:(id)value;
@end
@@ -27,6 +27,7 @@
NSDictionary* userInfo;
NSHTTPURLResponse* response;
+ NSDictionary* xDropboxMetadataJSON;
NSInteger bytesDownloaded;
CGFloat downloadProgress;
CGFloat uploadProgress;
@@ -56,8 +57,8 @@
@property (nonatomic, readonly) NSURLRequest* request;
@property (nonatomic, readonly) NSHTTPURLResponse* response;
+@property (nonatomic, readonly) NSDictionary* xDropboxMetadataJSON;
@property (nonatomic, readonly) NSInteger statusCode;
-@property (nonatomic, readonly) long long contentLength;
@property (nonatomic, readonly) CGFloat downloadProgress;
@property (nonatomic, readonly) CGFloat uploadProgress;
@property (nonatomic, readonly) NSData* resultData;
@@ -119,13 +119,14 @@
- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath;
// Implement the following callback instead of the previous if you care about the value of the
-// Content-Type HTTP header. Only one will be called per successful response.
-- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath contentType:(NSString*)contentType;
+// Content-Type HTTP header and the file metadata. Only one will be called per successful response.
+- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath contentType:(NSString*)contentType metadata:(DBMetadata*)metadata;
- (void)restClient:(DBRestClient*)client loadProgress:(CGFloat)progress forFile:(NSString*)destPath;
- (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error;
// [error userInfo] contains the destinationPath
-- (void)restClient:(DBRestClient*)client loadedThumbnail:(NSString*)destPath;
+
+- (void)restClient:(DBRestClient*)client loadedThumbnail:(NSString*)destPath metadata:(DBMetadata*)metadata;
- (void)restClient:(DBRestClient*)client loadThumbnailFailedWithError:(NSError*)error;
- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath from:(NSString*)srcPath
@@ -138,6 +139,10 @@
// Deprecated upload callback
- (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath from:(NSString*)srcPath;
+// Deprecated download callbacks
+- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath contentType:(NSString*)contentType;
+- (void)restClient:(DBRestClient*)client loadedThumbnail:(NSString*)destPath;
+
- (void)restClient:(DBRestClient*)client loadedRevisions:(NSArray *)revisions forFile:(NSString *)path;
- (void)restClient:(DBRestClient*)client loadRevisionsFailedWithError:(NSError *)error;
@@ -41,10 +41,15 @@
accepts and what it generates. For example, it does not support trailing commas
in arrays or objects. Nor does it support embedded comments, or
anything else not in the JSON specification. This is considered a feature.
+
+
+ SBJson has been renamed to DBJson in the DropboxSDK because static libraries
+ are unable to hide symbols and other libraries that developers use include
+ SBJson
*/
-#import "SBJSON.h"
-#import "NSObject+SBJSON.h"
-#import "NSString+SBJSON.h"
+#import "DBJSON.h"
+#import "NSObject+DBJSON.h"
+#import "NSString+DBJSON.h"
@@ -37,7 +37,7 @@
of standard objects to the objects themselves. This means you can call the
-JSONRepresentation method on an NSArray object and it'll do what you want.
*/
-@interface NSObject (NSObject_SBJSON)
+@interface NSObject (NSObject_DBJSON)
/**
@brief Returns a string containing the receiver encoded as a JSON fragment.
@@ -34,7 +34,7 @@
This is a category on NSString that adds methods for parsing the target string.
*/
-@interface NSString (NSString_SBJSON)
+@interface NSString (NSString_DBJSON)
/**
Binary file not shown.
Oops, something went wrong.

0 comments on commit 61f0971

Please sign in to comment.