Fix bug in sync daemon when deleting locally objects from different containers/accoun...
[pithos-macos] / pithos-macos / PithosSyncDaemon.m
index f84fbda..442bf7e 100644 (file)
                                 [PithosUtilities removeContentsAtPath:[self.tempDownloadsDirPath stringByAppendingPathComponent:containerName]];
                             }
                         } else {
-                            [PithosUtilities removeContentsAtPath:[[self.tempDownloadsDirPath stringByAppendingPathComponent:@"shared to me"] 
+                            [PithosUtilities removeContentsAtPath:[[self.tempDownloadsDirPath stringByAppendingPathComponent:@"shared with me"]
                                                                    stringByAppendingPathComponent:accountName]];
                         }
                     }
                             if ([accountName isEqualToString:@""])
                                 [PithosUtilities removeContentsAtPath:[self.tempDownloadsDirPath stringByAppendingPathComponent:containerName]];
                             else
-                                [PithosUtilities removeContentsAtPath:[[[self.tempDownloadsDirPath stringByAppendingPathComponent:@"shared to me"] 
+                                [PithosUtilities removeContentsAtPath:[[[self.tempDownloadsDirPath stringByAppendingPathComponent:@"shared with me"]
                                                                         stringByAppendingPathComponent:accountName] 
                                                                        stringByAppendingPathComponent:containerName]];
                             [accountStoredLocalObjectStates removeObjectForKey:containerName];
         pithos.storageURLPrefix = [aPithos.storageURLPrefix copy];
         pithos.authURL = [aPithos.authURL copy];
         pithos.publicURLPrefix = [aPithos.publicURLPrefix copy];
+        pithos.userCatalogURL = [aPithos.userCatalogURL copy];
     }
     if (aPithos && 
         (![aPithos.authUser isEqualToString:pithos.authUser] || 
         pithos.storageURLPrefix = [aPithos.storageURLPrefix copy];
         pithos.authURL = [aPithos.authURL copy];
         pithos.publicURLPrefix = [aPithos.publicURLPrefix copy];
-    }        
+        pithos.userCatalogURL = [aPithos.userCatalogURL copy];
+    }
 }
 
 #pragma mark -
     if ([accountName isEqualToString:@""])
         return [directoryPath stringByAppendingPathComponent:containerName];
     else
-        return [[[directoryPath stringByAppendingPathComponent:@"shared to me"] 
+        return [[[directoryPath stringByAppendingPathComponent:@"shared with me"]
                  stringByAppendingPathComponent:accountName] 
                 stringByAppendingPathComponent:containerName];
 }
     if ([accountName isEqualToString:@""])
         return containerName;
     else
-        return [[@"shared to me" stringByAppendingPathComponent:accountName] stringByAppendingPathComponent:containerName];
+        return [[@"shared with me" stringByAppendingPathComponent:accountName] stringByAppendingPathComponent:containerName];
 }
 
 #pragma mark -
         BOOL isDirectory;
         BOOL fileExists = [fileManager fileExistsAtPath:filePath isDirectory:&isDirectory];
         NSError *error = nil;
-        NSString *containerDirectoryPath = [self dirPathForAccount:accountName container:pithosContainer.name];
-        NSString *newFilePath = [filePath stringByReplacingOccurrencesOfString:containerDirectoryPath withString:self.tempTrashDirPath];
+        NSString *newFilePath = [filePath stringByReplacingOccurrencesOfString:directoryPath withString:self.tempTrashDirPath];
         NSString *newDirPath = [newFilePath stringByDeletingLastPathComponent];
         if (fileExists && isDirectory) {
             NSArray *subPaths = [fileManager subpathsOfDirectoryAtPath:filePath error:&error];
             }
             for (NSString *subPath in subPaths) {
                 NSString *subFilePath = [filePath stringByAppendingPathComponent:subPath];
-                NSString *newSubFilePath = [subFilePath stringByReplacingOccurrencesOfString:containerDirectoryPath 
+                NSString *newSubFilePath = [subFilePath stringByReplacingOccurrencesOfString:directoryPath
                                                                                   withString:self.tempTrashDirPath];
                 currentState = [currentLocalObjectStates objectForKey:subFilePath];
                 if (currentState) {
         if (!object || !object.objectHash) {
             // Delete local object
             if (![accountName isEqualToString:@""])
-                // If "shared to me" skip
+                // If "shared with me" skip
                 return;
             if (remoteObjectExists) {
                 // Remote object created in the meantime, just mark the sync cycle as incomplete, but do delete the local object
                     }
                 }
                 if (![object.allowedTo isEqualToString:@"write"]) {
-                    // If read-only "shared to me" skip
+                    // If read-only "shared with me" skip
                     [self syncOperationFinishedWithSuccess:YES];
                     return;
                 }
         } else if (![currentState exists]) {
             // Delete remote object
             if (![accountName isEqualToString:@""]) {
-                // If "shared to me" skip
+                // If "shared with me" skip
                 [self syncOperationFinishedWithSuccess:YES];
                 return;
             }
                     }
                 }
                 if (![object.allowedTo isEqualToString:@"write"]) {
-                    // If read-only "shared to me" skip
+                    // If read-only "shared with me" skip
                     [self syncOperationFinishedWithSuccess:YES];
                     return;
                 }