From 212a7d57436d6eb4590688ce246491f608f4fe8b Mon Sep 17 00:00:00 2001 From: Miltiadis Vasilakis Date: Thu, 13 Oct 2011 02:52:44 +0300 Subject: [PATCH] Added retry and improved activity for delete/create directory requests. --- pithos-macos/PithosActivity.h | 4 +- pithos-macos/PithosBrowserController.m | 240 ++++++++++++++++++++++---------- pithos-macos/PithosUtilities.h | 2 +- pithos-macos/PithosUtilities.m | 30 +++- 4 files changed, 194 insertions(+), 82 deletions(-) diff --git a/pithos-macos/PithosActivity.h b/pithos-macos/PithosActivity.h index 2e29ad7..c94b751 100644 --- a/pithos-macos/PithosActivity.h +++ b/pithos-macos/PithosActivity.h @@ -41,7 +41,9 @@ typedef enum { PithosActivityUpload, PithosActivityDownload, PithosActivityCopy, - PithosActivityMove + PithosActivityMove, + PithosActivityCreateDirectory, + PithosActivityDelete } PithosActivityType; @interface PithosActivity : NSObject { diff --git a/pithos-macos/PithosBrowserController.m b/pithos-macos/PithosBrowserController.m index fce0de3..0b42490 100644 --- a/pithos-macos/PithosBrowserController.m +++ b/pithos-macos/PithosBrowserController.m @@ -106,7 +106,7 @@ @implementation PithosBrowserController @synthesize accountNode; -@synthesize verticalSplitView, horizontalSplitView, leftTopView, leftBottomView, outlineView, browser; +@synthesize verticalSplitView, horizontalSplitView, leftTopView, leftBottomView, outlineView, browser, outlineViewMenu, browserMenu; @synthesize draggedNodes, draggedParentNode; @synthesize clipboardNodes, clipboardParentNode, clipboardCopy; @synthesize activityTextField, activityProgressIndicator; @@ -852,6 +852,14 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { objectRequest.delegate = self; objectRequest.didFinishSelector = @selector(uploadDirectoryObjectFinished:); objectRequest.didFailSelector = @selector(uploadDirectoryObjectFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityCreateDirectory + message:[NSString stringWithFormat:@"Creating directory '%@'", [objectRequest.userInfo valueForKey:@"fileName"]]]; + [(NSMutableDictionary *)objectRequest.userInfo addEntriesFromDictionary: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:YES], @"refresh", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", + nil]]; [[PithosUtilities prepareRequest:objectRequest] startAsynchronous]; } if (objectRequests) { @@ -1131,18 +1139,50 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { } - (void)uploadDirectoryObjectFinished:(ASIPithosObjectRequest *)objectRequest { - NSLog(@"Upload directory object completed: %@", [objectRequest url]); + NSLog(@"Upload directory object finished: %@", objectRequest.url); if (objectRequest.responseStatusCode == 201) { - NSLog(@"Directory object created: %@", [objectRequest url]); - [self refresh:nil]; + NSLog(@"Directory object created: %@", objectRequest.url); + [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] + withMessage:[NSString stringWithFormat:@"Creating directory '%@' (finished)", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + for (PithosNode *node in [objectRequest.userInfo objectForKey:@"forceRefreshNodes"]) { + [node forceRefresh]; + } + for (PithosNode *node in [objectRequest.userInfo objectForKey:@"refreshNodes"]) { + [node refresh]; + } + if ([[objectRequest.userInfo objectForKey:@"forceRefresh"] boolValue]) + [self forceRefresh:self]; + else if ([[objectRequest.userInfo objectForKey:@"refresh"] boolValue]) + [self refresh:self]; } else { - [PithosUtilities unexpectedResponseStatusAlertWithRequest:objectRequest]; + NSUInteger retries = [[objectRequest.userInfo objectForKey:@"retries"] unsignedIntegerValue]; + if (retries > 0) { + ASIPithosObjectRequest *newObjectRequest = (ASIPithosObjectRequest *)[PithosUtilities copyRequest:objectRequest]; + [(NSMutableDictionary *)(newObjectRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"]; + [[PithosUtilities prepareRequest:newObjectRequest] startAsynchronous]; + } else { + [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] + withMessage:[NSString stringWithFormat:@"Creating directory '%@' (failed)", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + [PithosUtilities unexpectedResponseStatusAlertWithRequest:objectRequest]; + } } } - (void)uploadDirectoryObjectFailed:(ASIPithosObjectRequest *)objectRequest { - NSLog(@"Upload directory object failed"); - [PithosUtilities httpRequestErrorAlertWithRequest:objectRequest]; + NSLog(@"Upload directory object failed: %@", objectRequest.url); + NSUInteger retries = [[objectRequest.userInfo objectForKey:@"retries"] unsignedIntegerValue]; + if (retries > 0) { + ASIPithosObjectRequest *newObjectRequest = (ASIPithosObjectRequest *)[PithosUtilities copyRequest:objectRequest]; + [(NSMutableDictionary *)(newObjectRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"]; + [[PithosUtilities prepareRequest:newObjectRequest] startAsynchronous]; + } else { + [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] + withMessage:[NSString stringWithFormat:@"Creating directory '%@' (failed)", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + [PithosUtilities httpRequestErrorAlertWithRequest:objectRequest]; + } } - (void)uploadObjectUsingHashMapFinished:(ASIPithosObjectRequest *)objectRequest { @@ -1372,7 +1412,7 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { [[PithosUtilities prepareRequest:newObjectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; } else { [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] - withMessage:[NSString stringWithFormat:@"Moving '%@/%@' to '%@/%@' failed", + withMessage:[NSString stringWithFormat:@"Moving '%@/%@' to '%@/%@' (failed)", [objectRequest.userInfo objectForKey:@"sourceContainerName"], [objectRequest.userInfo objectForKey:@"sourceObjectName"], [objectRequest.userInfo objectForKey:@"destinationContainerName"], @@ -1427,7 +1467,7 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { [[PithosUtilities prepareRequest:newObjectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; } else { [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] - withMessage:[NSString stringWithFormat:@"Copying '%@/%@' to '%@/%@' failed", + withMessage:[NSString stringWithFormat:@"Copying '%@/%@' to '%@/%@' (failed)", [objectRequest.userInfo objectForKey:@"sourceContainerName"], [objectRequest.userInfo objectForKey:@"sourceObjectName"], [objectRequest.userInfo objectForKey:@"destinationContainerName"], @@ -1436,6 +1476,52 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { } } +- (void)deleteObjectFinished:(ASIPithosObjectRequest *)objectRequest { + NSLog(@"Delete object finished: %@", objectRequest.url); + if (objectRequest.responseStatusCode == 204) { + [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] + withMessage:[NSString stringWithFormat:@"Deleting '%@' (finished)", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + for (PithosNode *node in [objectRequest.userInfo objectForKey:@"forceRefreshNodes"]) { + [node forceRefresh]; + } + for (PithosNode *node in [objectRequest.userInfo objectForKey:@"refreshNodes"]) { + [node refresh]; + } + if ([[objectRequest.userInfo objectForKey:@"forceRefresh"] boolValue]) + [self forceRefresh:self]; + else if ([[objectRequest.userInfo objectForKey:@"refresh"] boolValue]) + [self refresh:self]; + } else { + NSUInteger retries = [[objectRequest.userInfo objectForKey:@"retries"] unsignedIntegerValue]; + if (retries > 0) { + ASIPithosObjectRequest *newObjectRequest = (ASIPithosObjectRequest *)[PithosUtilities copyRequest:objectRequest]; + [(NSMutableDictionary *)(newObjectRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"]; + [[PithosUtilities prepareRequest:newObjectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; + } else { + [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] + withMessage:[NSString stringWithFormat:@"Deleting '%@' (failed)", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + [PithosUtilities unexpectedResponseStatusAlertWithRequest:objectRequest]; + } + } +} + +- (void)deleteObjectFailed:(ASIPithosObjectRequest *)objectRequest { + NSLog(@"Delete object failed: %@", objectRequest.url); + NSUInteger retries = [[objectRequest.userInfo objectForKey:@"retries"] unsignedIntegerValue]; + if (retries > 0) { + ASIPithosObjectRequest *newObjectRequest = (ASIPithosObjectRequest *)[PithosUtilities copyRequest:objectRequest]; + [(NSMutableDictionary *)(newObjectRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"]; + [[PithosUtilities prepareRequest:newObjectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; + } else { + [activityFacility endActivity:[objectRequest.userInfo objectForKey:@"activity"] + withMessage:[NSString stringWithFormat:@"Deleting '%@' (failed)", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + [PithosUtilities httpRequestErrorAlertWithRequest:objectRequest]; + } +} + #pragma mark - #pragma mark NSSplitViewDelegate @@ -1743,6 +1829,7 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { dispatch_async(queue, ^{ NSString *safeObjectName = [PithosUtilities safeSubdirNameForContainerName:node.pithosContainer.name subdirName:@"untitled folder"]; + NSString *fileName = [safeObjectName lastPathComponent]; ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithContainerName:node.pithosContainer.name objectName:safeObjectName eTag:nil @@ -1755,20 +1842,26 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { metadata:nil data:[NSData data]]; objectRequest.delegate = self; - objectRequest.didFinishSelector = @selector(newFolderFinished:); - objectRequest.didFailSelector = @selector(newFolderFailed:); + objectRequest.didFinishSelector = @selector(uploadDirectoryObjectFinished:); + objectRequest.didFailSelector = @selector(uploadDirectoryObjectFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityCreateDirectory + message:[NSString stringWithFormat:@"Creating directory '%@'", fileName]]; objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: - node, @"node", + fileName, @"fileName", + [NSArray arrayWithObject:node], @"refreshNodes", + [NSNumber numberWithBool:YES], @"refresh", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", nil]; [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; }); } else if (([node class] == [PithosSubdirNode class]) && - (node.pithosObject.subdir || - ![node.pithosObject.name hasSuffix:@"/"])) { + (node.pithosObject.subdir || ![node.pithosObject.name hasSuffix:@"/"])) { dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^{ NSString *safeObjectName = [PithosUtilities safeSubdirNameForContainerName:node.pithosContainer.name subdirName:[node.pithosObject.name stringByAppendingPathComponent:@"untitled folder"]]; + NSString *fileName = [safeObjectName lastPathComponent]; ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithContainerName:node.pithosContainer.name objectName:safeObjectName eTag:nil @@ -1781,11 +1874,17 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { metadata:nil data:[NSData data]]; objectRequest.delegate = self; - objectRequest.didFinishSelector = @selector(newFolderFinished:); - objectRequest.didFailSelector = @selector(newFolderFailed:); + objectRequest.didFinishSelector = @selector(uploadDirectoryObjectFinished:); + objectRequest.didFailSelector = @selector(uploadDirectoryObjectFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityCreateDirectory + message:[NSString stringWithFormat:@"Creating directory '%@'", fileName]]; objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: - node, @"node", - nil]; + fileName, @"fileName", + [NSArray arrayWithObject:node], @"refreshNodes", + [NSNumber numberWithBool:YES], @"refresh", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", + nil]; [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; }); } @@ -1800,25 +1899,41 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { - (void)menuDelete:(NSMenuItem *)sender { for (PithosNode *node in ((NSArray *)[sender representedObject])) { if (([node class] == [PithosObjectNode class]) || - (([node class] == [PithosSubdirNode class]) && - !node.pithosObject.subdir && - [node.pithosObject.name hasSuffix:@"/"])) { + (([node class] == [PithosSubdirNode class]) && !node.pithosObject.subdir && [node.pithosObject.name hasSuffix:@"/"])) { ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:node.pithosContainer.name objectName:node.pithosObject.name]; objectRequest.delegate = self; objectRequest.didFinishSelector = @selector(deleteObjectFinished:); objectRequest.didFailSelector = @selector(deleteObjectFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityDelete + message:[NSString stringWithFormat:@"Deleting '%@'", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + [(NSMutableDictionary *)(objectRequest.userInfo) addEntriesFromDictionary: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObject:node.parent], @"forceRefreshNodes", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", + nil]]; [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; } else if ([node class] == [PithosSubdirNode class]) { dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^{ NSArray *objectRequests = [PithosUtilities deleteObjectRequestsForSubdirWithContainerName:node.pithosContainer.name - objectName:node.pithosObject.name]; + objectName:node.pithosObject.name]; if (objectRequests) { for (ASIPithosObjectRequest *objectRequest in objectRequests) { objectRequest.delegate = self; objectRequest.didFinishSelector = @selector(deleteObjectFinished:); objectRequest.didFailSelector = @selector(deleteObjectFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityDelete + message:[NSString stringWithFormat:@"Deleting '%@'", + [objectRequest.userInfo objectForKey:@"fileName"]]]; + [(NSMutableDictionary *)(objectRequest.userInfo) addEntriesFromDictionary: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObject:node.parent], @"forceRefreshNodes", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", + nil]]; [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; } } @@ -1845,8 +1960,20 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { checkIfExists:NO]; if (objectRequest) { objectRequest.delegate = self; - objectRequest.didFinishSelector = @selector(moveToTrashFinished:); - objectRequest.didFailSelector = @selector(moveToTrashFailed:); + objectRequest.didFinishSelector = @selector(moveFinished:); + objectRequest.didFailSelector = @selector(moveFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityMove + message:[NSString stringWithFormat:@"Moving '%@/%@' to '%@/%@'", + [objectRequest.userInfo objectForKey:@"sourceContainerName"], + [objectRequest.userInfo objectForKey:@"sourceObjectName"], + [objectRequest.userInfo objectForKey:@"destinationContainerName"], + [objectRequest.userInfo objectForKey:@"destinationObjectName"]]]; + [(NSMutableDictionary *)(objectRequest.userInfo) addEntriesFromDictionary: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObject:node.parent], @"forceRefreshNodes", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", + nil]]; [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; } } @@ -1865,8 +1992,20 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { if (objectRequests) { for (ASIPithosObjectRequest *objectRequest in objectRequests) { objectRequest.delegate = self; - objectRequest.didFinishSelector = @selector(moveToTrashFinished:); - objectRequest.didFailSelector = @selector(moveToTrashFailed:); + objectRequest.didFinishSelector = @selector(moveFinished:); + objectRequest.didFailSelector = @selector(moveFailed:); + PithosActivity *activity = [activityFacility startActivityWithType:PithosActivityMove + message:[NSString stringWithFormat:@"Moving '%@/%@' to '%@/%@'", + [objectRequest.userInfo objectForKey:@"sourceContainerName"], + [objectRequest.userInfo objectForKey:@"sourceObjectName"], + [objectRequest.userInfo objectForKey:@"destinationContainerName"], + [objectRequest.userInfo objectForKey:@"destinationObjectName"]]]; + [(NSMutableDictionary *)(objectRequest.userInfo) addEntriesFromDictionary: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObject:node.parent], @"forceRefreshNodes", + activity, @"activity", + [NSNumber numberWithUnsignedInteger:10], @"retries", + nil]]; [[PithosUtilities prepareRequest:objectRequest priority:NSOperationQueuePriorityVeryHigh] startAsynchronous]; } } @@ -1903,55 +2042,6 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { } #pragma mark - -#pragma mark Menu Actions ASIHTTPRequestDelegate - -- (void)newFolderFinished:(ASIPithosObjectRequest *)objectRequest { - if (objectRequest.responseStatusCode == 201) { - NSLog(@"New application/directory object created: %@", [objectRequest url]); - PithosNode *node = [objectRequest.userInfo objectForKey:@"node"]; - if (node) - [node refresh]; - else - [self refresh:nil]; - } else { - [PithosUtilities unexpectedResponseStatusAlertWithRequest:objectRequest]; - } -} - -- (void)newFolderFailed:(ASIPithosObjectRequest *)objectRequest { - NSLog(@"Creation of new application/directory object failed"); - [PithosUtilities httpRequestErrorAlertWithRequest:objectRequest]; -} - -- (void)deleteObjectFinished:(ASIPithosObjectRequest *)objectRequest { - if (objectRequest.responseStatusCode == 204) { - NSLog(@"Object deleted: %@", [objectRequest url]); - [self refresh:nil]; - } else { - [PithosUtilities unexpectedResponseStatusAlertWithRequest:objectRequest]; - } -} - -- (void)deleteObjectFailed:(ASIPithosObjectRequest *)objectRequest { - NSLog(@"Delete of object failed"); - [PithosUtilities httpRequestErrorAlertWithRequest:objectRequest]; -} - -- (void)moveToTrashFinished:(ASIPithosObjectRequest *)objectRequest { - if (objectRequest.responseStatusCode == 201) { - NSLog(@"Object moved: %@", [objectRequest url]); - [self refresh:nil]; - } else { - [PithosUtilities unexpectedResponseStatusAlertWithRequest:objectRequest]; - } -} - -- (void)moveToTrashFailed:(ASIPithosObjectRequest *)objectRequest { - NSLog(@"Move of object failed"); - [PithosUtilities httpRequestErrorAlertWithRequest:objectRequest]; -} - -#pragma mark - #pragma mark PithosActivityFacilityDelegate - (void)activityUpdate:(NSDictionary *)info { diff --git a/pithos-macos/PithosUtilities.h b/pithos-macos/PithosUtilities.h index 0b8269a..ff7fcc0 100644 --- a/pithos-macos/PithosUtilities.h +++ b/pithos-macos/PithosUtilities.h @@ -1,5 +1,5 @@ // -// PithosFileUtilities.h +// PithosUtilities.h // pithos-macos // // Copyright 2011 GRNET S.A. All rights reserved. diff --git a/pithos-macos/PithosUtilities.m b/pithos-macos/PithosUtilities.m index 5e78e47..e69dfa5 100644 --- a/pithos-macos/PithosUtilities.m +++ b/pithos-macos/PithosUtilities.m @@ -1,5 +1,5 @@ // -// PithosFileUtilities.m +// PithosUtilities.m // pithos-macos // // Copyright 2011 GRNET S.A. All rights reserved. @@ -361,6 +361,9 @@ data:[NSData data]]; if (sharingAccount) [objectRequest setRequestUserFromDefaultTo:sharingAccount]; + objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: + [directoryPath lastPathComponent], @"fileName", + nil]; [*directoryObjectRequests addObject:objectRequest]; NSMutableArray *objectRequests = [NSMutableArray arrayWithCapacity:[subPaths count]]; @@ -420,6 +423,7 @@ } else { subObjectName = [objectName stringByAppendingPathComponent:objectNameSuffix]; + fileName = [filePath lastPathComponent]; objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithContainerName:containerName objectName:subObjectName eTag:nil @@ -433,6 +437,9 @@ data:[NSData data]]; if (sharingAccount) [objectRequest setRequestUserFromDefaultTo:sharingAccount]; + objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: + fileName, @"fileName", + nil]; [*directoryObjectRequests addObject:objectRequest]; } } @@ -450,11 +457,24 @@ return nil; NSMutableArray *objectRequests = [NSMutableArray arrayWithCapacity:([objects count] + 1)]; - - if (![objectName hasSuffix:@"/"]) - [objectRequests addObject:[ASIPithosObjectRequest deleteObjectRequestWithContainerName:containerName objectName:objectName]]; + ASIPithosObjectRequest *objectRequest; + if (![objectName hasSuffix:@"/"]) { + objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:containerName objectName:objectName]; + objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: + [objectName lastPathComponent], @"fileName", + nil]; + [objectRequests addObject:objectRequest]; + } + NSString *fileName; for (ASIPithosObject *object in objects) { - [objectRequests addObject:[ASIPithosObjectRequest deleteObjectRequestWithContainerName:containerName objectName:object.name]]; + fileName = [object.name lastPathComponent]; + if ([object.name hasSuffix:@"/"]) + fileName = [fileName stringByAppendingString:@"/"]; + objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:containerName objectName:object.name]; + objectRequest.userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: + fileName, @"fileName", + nil]; + [objectRequests addObject:objectRequest]; } if ([objectRequests count] == 0) -- 1.7.10.4