- NSString *filePath = [containerDirectoryPath stringByAppendingPathComponent:objectName];
- NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
- BOOL isDirectory;
- BOOL fileExists = [fileManager fileExistsAtPath:filePath isDirectory:&isDirectory];
- if ([[attributes fileType] isEqualToString:NSFileTypeSymbolicLink]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [PithosUtilities fileActionFailedAlertWithTitle:@"Sync Error"
- message:[NSString stringWithFormat:@"Sync directory at '%@' contains symbolic links. Remove them and re-activate sync for account '%@'.",
- containerDirectoryPath, pithosAccount.name]
- error:nil];
- });
- pithosAccount.syncActive = NO;
- return;
- } else if (fileExists) {
- NSArray *pathComponents = [objectName pathComponents];
- if ([pathComponents count] == 1) {
- if ([containerExcludedDirectories containsObject:[objectName lowercaseString]]) {
- // Skip excluded directory and its descendants, or root file with same name
- if (isDirectory)
- [dirEnumerator skipDescendants];
- // Remove stored state if any
- [containerStoredLocalObjectStates removeObjectForKey:objectName];
- continue;
- } else if (!isDirectory && containerExludeRootFiles) {
- // Skip excluded root file
- // Remove stored state if any
- [containerStoredLocalObjectStates removeObjectForKey:objectName];
- continue;
+ NSString *filePath = [containerDirectoryPath stringByAppendingPathComponent:objectName];
+ NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
+ BOOL isDirectory;
+ BOOL fileExists = [fileManager fileExistsAtPath:filePath isDirectory:&isDirectory];
+ if ([[attributes fileType] isEqualToString:NSFileTypeSymbolicLink]) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [PithosUtilities fileActionFailedAlertWithTitle:@"Sync Error"
+ message:[NSString stringWithFormat:@"Sync directory at '%@' contains symbolic links. Remove them and re-activate sync for account '%@'.",
+ containerDirectoryPath, pithosAccount.name]
+ error:nil];
+ });
+ pithosAccount.syncActive = NO;
+ return;
+ } else if (fileExists) {
+ NSArray *pathComponents = [objectName pathComponents];
+ if ([pathComponents count] == 1) {
+ if ([containerExcludedDirectories containsObject:[objectName lowercaseString]]) {
+ // Skip excluded directory and its descendants, or root file with same name
+ if (isDirectory)
+ [dirEnumerator skipDescendants];
+ // Remove stored state if any
+ [containerStoredLocalObjectStates removeObjectForKey:objectName];
+ continue;
+ } else if (!isDirectory && containerExludeRootFiles) {
+ // Skip excluded root file
+ // Remove stored state if any
+ [containerStoredLocalObjectStates removeObjectForKey:objectName];
+ continue;
+ }
+ }
+ // Include local object
+ PithosLocalObjectState *storedLocalObjectState = [containerStoredLocalObjectStates objectForKey:objectName];
+ if (!storedLocalObjectState || [storedLocalObjectState isModified]) {
+ // New or modified existing local object, compute current state
+ if (!storedLocalObjectState)
+ // For new local object, also create empty stored state
+ [containerStoredLocalObjectStates setObject:[PithosLocalObjectState localObjectState] forKey:objectName];
+ [currentLocalObjectStates setObject:[PithosLocalObjectState localObjectStateWithFile:filePath
+ blockHash:pithosContainer.blockHash
+ blockSize:pithosContainer.blockSize]
+ forKey:filePath];
+ } else {
+ // Local object hasn't changed, set stored state also to current
+ [currentLocalObjectStates setObject:storedLocalObjectState forKey:filePath];