Revision 0224a49f pithos-macos/PithosBrowserController.m

b/pithos-macos/PithosBrowserController.m
97 97

  
98 98
@end
99 99

  
100
@interface PithosBrowserController (Private) {}
100
@interface PithosBrowserController (Private)
101 101
- (void)resetContainers:(NSNotification *)notification;
102 102
- (BOOL)uploadFiles:(NSArray *)filenames toNode:(PithosNode *)destinationNode;
103 103
- (BOOL)moveNodes:(NSArray *)nodes toNode:(PithosNode *)destinationNode;
......
741 741
- (BOOL)uploadFiles:(NSArray *)filenames toNode:(PithosNode *)destinationNode {
742 742
    if (([destinationNode class] != [PithosSubdirNode class]) && ([destinationNode class] != [PithosContainerNode class]))
743 743
        return NO;
744
    NSFileManager *defaultManager = [NSFileManager defaultManager];
744
    NSFileManager *fileManager = [NSFileManager defaultManager];
745 745
    NSString *containerName = [NSString stringWithString:destinationNode.pithosContainer.name];
746 746
    NSString *objectNamePrefix;
747 747
    if ([destinationNode class] == [PithosSubdirNode class])
......
757 757
        if ([containerRequest error]) {
758 758
            [PithosUtilities httpRequestErrorAlertWithRequest:containerRequest];
759 759
            return NO;
760
        } else if (containerRequest.responseStatusCode != 200) {
760
        } else if (containerRequest.responseStatusCode != 204) {
761 761
            [PithosUtilities unexpectedResponseStatusAlertWithRequest:containerRequest];
762 762
            return NO;
763 763
        }
......
769 769
    
770 770
    for (NSString *filePath in filenames) {
771 771
        BOOL isDirectory;
772
        if ([defaultManager fileExistsAtPath:filePath isDirectory:&isDirectory]) {
772
        if ([fileManager fileExistsAtPath:filePath isDirectory:&isDirectory]) {
773 773
            if (!isDirectory) {
774 774
                // Upload file
775 775
                NSString *objectName = [objectNamePrefix stringByAppendingPathComponent:[filePath lastPathComponent]];
......
1088 1088
        // XXX change contentLength to objectContentLength if it is fixed in the server
1089 1089
        if (([objectRequest contentLength] == 0) && (![[objectRequest contentType] isEqualToString:@"application/directory"])) {
1090 1090
            NSLog(@"Downloaded  0 bytes");
1091
            NSFileManager *defaultManager = [NSFileManager defaultManager];
1092
            if (![defaultManager fileExistsAtPath:filePath]) {
1093
                if (![defaultManager createFileAtPath:filePath contents:nil attributes:nil]) {
1091
            NSFileManager *fileManager = [NSFileManager defaultManager];
1092
            if (![fileManager fileExistsAtPath:filePath]) {
1093
                if (![fileManager createFileAtPath:filePath contents:nil attributes:nil]) {
1094 1094
                    NSAlert *alert = [[[NSAlert alloc] init] autorelease];
1095 1095
                    [alert setMessageText:@"Create File Error"];
1096 1096
                    [alert setInformativeText:[NSString stringWithFormat:@"Cannot create zero length file at %@", filePath]];
......
1900 1900
    for (PithosNode *node in ((NSArray *)[sender representedObject])) {
1901 1901
        if (([node class] == [PithosObjectNode class]) || 
1902 1902
            (([node class] == [PithosSubdirNode class]) && !node.pithosObject.subdir && [node.pithosObject.name hasSuffix:@"/"])) {
1903
            NSString *fileName = [node.pithosObject.name lastPathComponent];
1904
            if ([node.pithosObject.name hasSuffix:@"/"])
1905
                fileName = [fileName stringByAppendingString:@"/"];
1903 1906
            ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:node.pithosContainer.name 
1904 1907
                                                                                                      objectName:node.pithosObject.name];
1905 1908
            objectRequest.delegate = self;
1906 1909
            objectRequest.didFinishSelector = @selector(deleteObjectFinished:);
1907 1910
            objectRequest.didFailSelector = @selector(deleteObjectFailed:);
1908 1911
            PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityDelete 
1909
                                                                       message:[NSString stringWithFormat:@"Deleting '%@'", 
1910
                                                                                [objectRequest.userInfo objectForKey:@"fileName"]]];
1911
            [(NSMutableDictionary *)(objectRequest.userInfo) addEntriesFromDictionary:
1912
             [NSDictionary dictionaryWithObjectsAndKeys:
1913
              [NSArray arrayWithObject:node.parent], @"forceRefreshNodes", 
1914
              activity, @"activity", 
1915
              [NSNumber numberWithUnsignedInteger:10], @"retries", 
1916
              nil]];
1912
                                                                       message:[NSString stringWithFormat:@"Deleting '%@'", fileName]];
1913
            objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys:
1914
                                      fileName, @"fileName", 
1915
                                      [NSArray arrayWithObject:node.parent], @"forceRefreshNodes", 
1916
                                      activity, @"activity", 
1917
                                      [NSNumber numberWithUnsignedInteger:10], @"retries", 
1918
                                      nil];
1917 1919
            [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous];
1918 1920
        } else if ([node class] == [PithosSubdirNode class]) {
1919 1921
            dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

Also available in: Unified diff