Revision d8426ffb pithos-macos/PithosSubdirNode.m

b/pithos-macos/PithosSubdirNode.m
41 41
#import "ASIPithosObjectRequest.h"
42 42
#import "ASIPithosContainer.h"
43 43
#import "ASIPithosObject.h"
44
#import "ASINetworkQueue.h"
44 45
#import "ASIDownloadCache.h"
45 46
#import "PithosUtilities.h"
46 47
#import "PithosObjectNodeInfoController.h"
......
84 85
#pragma mark -
85 86
#pragma mark Properties
86 87

  
88
- (void)setPithos:(ASIPithos *)aPithos {
89
    if (aPithos && ![aPithos isEqualTo:pithos]) {
90
        [pithos release];
91
        pithos = [aPithos retain];
92
        [url release];
93
        url = nil;
94
    }
95
}
96

  
87 97
- (NSString *)url {
88 98
    if (url == nil)
89 99
        url = [[NSString alloc] initWithFormat:@"subdir %@/%@/%@%@", 
......
167 177

  
168 178
- (void)objectRequestFailed:(ASIPithosObjectRequest *)request {
169 179
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
170
    if ([request isEqualTo:applyMetadataObjectRequest]) {
171
        [PithosUtilities httpRequestErrorAlertWithRequest:applyMetadataObjectRequest];
172
        @synchronized(self) {
173
            [applyMetadataObjectRequest release];
174
            applyMetadataObjectRequest = nil;
180
    NSUInteger retries = [[request.userInfo objectForKey:@"retries"] unsignedIntegerValue];
181
    if (retries > 0) {
182
        ASIPithosObjectRequest *newRequest = (ASIPithosObjectRequest *)[PithosUtilities copyRequest:request];
183
        [(NSMutableDictionary *)(newRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"];
184
        if ([request isEqualTo:applyMetadataObjectRequest]) {
185
            @synchronized(self) {
186
                [applyMetadataObjectRequest release];
187
                applyMetadataObjectRequest = newRequest;
188
            }
189
        } else if ([request isEqualTo:refreshMetadataObjectRequest]) {
190
            @synchronized(self) {
191
                [refreshMetadataObjectRequest release];
192
                refreshMetadataObjectRequest = newRequest;
193
            }
175 194
        }
176
    } else if ([request isEqualTo:refreshMetadataObjectRequest]) {
177
        [PithosUtilities httpRequestErrorAlertWithRequest:refreshMetadataObjectRequest];
178
        @synchronized(self) {
179
            [refreshMetadataObjectRequest release];
180
            refreshMetadataObjectRequest = nil;
195
        [[PithosUtilities prepareRequest:newRequest priority:[[newRequest.userInfo objectForKey:@"priority"] integerValue]] startAsynchronous];
196
    } else {
197
        if ([request isEqualTo:applyMetadataObjectRequest]) {
198
            dispatch_async(dispatch_get_main_queue(), ^{
199
                [PithosUtilities httpRequestErrorAlertWithRequest:applyMetadataObjectRequest];
200
            });
201
            @synchronized(self) {
202
                [applyMetadataObjectRequest release];
203
                applyMetadataObjectRequest = nil;
204
            }
205
        } else if ([request isEqualTo:refreshMetadataObjectRequest]) {
206
            dispatch_async(dispatch_get_main_queue(), ^{
207
                [PithosUtilities httpRequestErrorAlertWithRequest:refreshMetadataObjectRequest];
208
            });
209
            @synchronized(self) {
210
                [refreshMetadataObjectRequest release];
211
                refreshMetadataObjectRequest = nil;
212
            }
181 213
        }
182 214
    }
183 215
    [pool drain];
......
195 227
                ASIPithosObjectRequest *request = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos 
196 228
                                                                                            containerName:pithosContainer.name 
197 229
                                                                                               objectName:prefix];
198
                [[PithosUtilities prepareRequest:request] startAsynchronous];
199
                while (![request isFinished]) {
200
                    usleep(1);
201
                }
230
                ASINetworkQueue *networkQueue = [ASINetworkQueue queue];
231
                [networkQueue go];
232
                [networkQueue addOperations:[NSArray arrayWithObject:[PithosUtilities prepareRequest:request]] waitUntilFinished:YES];
202 233
                if ([request error]) {
203 234
                    alert = [[[NSAlert alloc] init] autorelease];
204 235
                    [alert setMessageText:@"HTTP Request Error"];
......
217 248
                        request = [ASIPithosObjectRequest deleteObjectRequestWithPithos:pithos 
218 249
                                                                          containerName:pithosContainer.name 
219 250
                                                                             objectName:prefix];
220
                        [[PithosUtilities prepareRequest:request] startAsynchronous];
221
                        while (![request isFinished]) {
222
                            usleep(1);
223
                        }
251
                        ASINetworkQueue *networkQueue = [ASINetworkQueue queue];
252
                        [networkQueue go];
253
                        [networkQueue addOperations:[NSArray arrayWithObject:[PithosUtilities prepareRequest:request]] waitUntilFinished:YES];
224 254
                        if ([request error]) {
225 255
                            alert = [[[NSAlert alloc] init] autorelease];
226 256
                            [alert setMessageText:@"HTTP Request Error"];

Also available in: Unified diff