Revision 9ab4b378
b/pithos-macos/PithosBrowserController.m | ||
---|---|---|
1093 | 1093 |
NSUInteger currentBytes = activity.currentBytes; |
1094 | 1094 |
|
1095 | 1095 |
// XXX change contentLength to objectContentLength if it is fixed in the server |
1096 |
if (([objectRequest contentLength] == 0) && (![[objectRequest contentType] isEqualToString:@"application/directory"])) {
|
|
1096 |
if (([objectRequest contentLength] == 0) && ![PithosUtilities isContentTypeDirectory:[objectRequest contentType]]) {
|
|
1097 | 1097 |
NSLog(@"Downloaded 0 bytes"); |
1098 | 1098 |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
1099 | 1099 |
if (![fileManager fileExistsAtPath:filePath]) { |
b/pithos-macos/PithosContainerNode.m | ||
---|---|---|
217 | 217 |
// The check above removes false objects due to trailing slash or same prefix |
218 | 218 |
if (object.subdir) { |
219 | 219 |
NSUInteger sameNameObjectIndex = [objectNames indexOfObject:[object.name substringToIndex:([object.name length] - 1)]]; |
220 |
if ((sameNameObjectIndex == NSNotFound) || |
|
221 |
![[[objects objectAtIndex:sameNameObjectIndex] contentType] isEqualToString:@"application/directory"]) {
|
|
220 |
if ((sameNameObjectIndex == NSNotFound) ||
|
|
221 |
![PithosUtilities isContentTypeDirectory:[[objects objectAtIndex:sameNameObjectIndex] contentType]]) {
|
|
222 | 222 |
PithosSubdirNode *node = [[[PithosSubdirNode alloc] initWithPithosContainer:pithosContainer pithosObject:object] autorelease]; |
223 | 223 |
node.parent = self; |
224 | 224 |
node.shared = shared; |
... | ... | |
237 | 237 |
node.pithosObject.allowedTo = [NSString stringWithString:@"read"]; |
238 | 238 |
[newChildren addObject:node]; |
239 | 239 |
} |
240 |
} else if ([object.contentType isEqualToString:@"application/directory"]) {
|
|
240 |
} else if ([PithosUtilities isContentTypeDirectory:object.contentType]) {
|
|
241 | 241 |
PithosSubdirNode *node = [[[PithosSubdirNode alloc] initWithPithosContainer:pithosContainer pithosObject:object] autorelease]; |
242 | 242 |
node.parent = self; |
243 | 243 |
node.shared = shared; |
b/pithos-macos/PithosSyncDaemon.m | ||
---|---|---|
524 | 524 |
[storedLocalObjectStates removeObjectForKey:object.name]; |
525 | 525 |
[self saveLocalState]; |
526 | 526 |
} |
527 |
} else if ([object.contentType isEqualToString:@"application/directory"]) {
|
|
527 |
} else if ([PithosUtilities isContentTypeDirectory:object.contentType]) {
|
|
528 | 528 |
// Create local directory object |
529 | 529 |
NSLog(@"Sync::create local directory object: %@", filePath); |
530 | 530 |
BOOL directoryCreated = NO; |
... | ... | |
866 | 866 |
PithosLocalObjectState *remoteObjectState = [PithosLocalObjectState localObjectState]; |
867 | 867 |
ASIPithosObject *remoteObject = [remoteObjects objectForKey:objectName]; |
868 | 868 |
if (remoteObject) { |
869 |
if ([remoteObject.contentType isEqualToString:@"application/directory"]) {
|
|
869 |
if ([PithosUtilities isContentTypeDirectory:remoteObject.contentType]) {
|
|
870 | 870 |
remoteObjectState.isDirectory = YES; |
871 | 871 |
object.contentType = @"application/directory"; |
872 | 872 |
} else { |
b/pithos-macos/PithosUtilities.h | ||
---|---|---|
126 | 126 |
|
127 | 127 |
+ (NSUInteger)bytesOfFile:(NSString *)filePath; |
128 | 128 |
+ (NSString *)contentTypeOfFile:(NSString *)filePath error:(NSError **)error; |
129 |
+ (BOOL)isContentTypeDirectory:(NSString *)contentType; |
|
129 | 130 |
+ (BOOL)objectExistsAtContainerName:(NSString *)containerName objectName:(NSString *)objectName |
130 | 131 |
error:(NSError **)error isDirectory:(BOOL *)isDirectory sharingAccount:(NSString *)sharingAccount; |
131 | 132 |
+ (BOOL)proceedIfObjectExistsAtContainerName:(NSString *)containerName objectName:(NSString *)objectName |
b/pithos-macos/PithosUtilities.m | ||
---|---|---|
141 | 141 |
} |
142 | 142 |
|
143 | 143 |
for (ASIPithosObject *object in objects) { |
144 |
if ([object.contentType isEqualToString:@"application/directory"]) {
|
|
144 |
if ([PithosUtilities isContentTypeDirectory:object.contentType]) {
|
|
145 | 145 |
NSString *subdirDirectoryPath = [directoryPath stringByAppendingPathComponent:subdirName]; |
146 | 146 |
subdirDirectoryPath = [subdirDirectoryPath stringByAppendingPathComponent:[object.name substringFromIndex:subdirPrefixLength]]; |
147 | 147 |
|
... | ... | |
840 | 840 |
return [response MIMEType]; |
841 | 841 |
} |
842 | 842 |
|
843 |
// Returns if an object is a directory based on its content type |
|
844 |
+ (BOOL)isContentTypeDirectory:(NSString *)contentType { |
|
845 |
return ([contentType isEqualToString:@"application/directory"] || |
|
846 |
[contentType hasPrefix:@"application/directory;"] || |
|
847 |
[contentType isEqualToString:@"application/folder"] || |
|
848 |
[contentType hasPrefix:@"application/folder;"]); |
|
849 |
} |
|
850 |
|
|
843 | 851 |
// Returns if an object exists at the given container/object path and if this object is an application/directory |
844 | 852 |
// If an error occured an alert is shown and it is returned so the caller won't proceed |
845 | 853 |
+ (BOOL)objectExistsAtContainerName:(NSString *)containerName objectName:(NSString *)objectName |
... | ... | |
858 | 866 |
[self httpRequestErrorAlertWithRequest:objectRequest]; |
859 | 867 |
return NO; |
860 | 868 |
} else if (objectRequest.responseStatusCode == 200) { |
861 |
*isDirectory = [[objectRequest contentType] isEqualToString:@"application/directory"];
|
|
869 |
*isDirectory = [self isContentTypeDirectory:[objectRequest contentType]];
|
|
862 | 870 |
return YES; |
863 | 871 |
} |
864 | 872 |
return NO; |
Also available in: Unified diff