Add preference to skip hidden files during sync.
[pithos-macos] / pithos-macos / PithosPreferencesController.m
index 35f24f2..aa00b9a 100644 (file)
@@ -70,7 +70,7 @@
 @synthesize accountsArrayController;
 @synthesize accountRemoveEnable;
 @synthesize serverURL, authUser, authToken, manual, loginEnable, loginCancelEnable;
-@synthesize syncActive, syncDirectoryPath, syncAccountsDictionary, syncApplyEnable, syncCancelEnable, 
+@synthesize syncActive, syncSkipHidden, syncDirectoryPath, syncAccountsDictionary, syncApplyEnable, syncCancelEnable, 
             syncAccountsOutlineView, syncAccountsRootFilesNodes;
 @synthesize groupsDictionaryController, selectedGroupMembersDictionaryController;
 
     BOOL isDirectory;
     self.syncApplyEnable = (selectedPithosAccount.active && 
                             ((selectedPithosAccount.syncActive != syncActive) || 
+                             (selectedPithosAccount.syncSkipHidden != syncSkipHidden) || 
                              (![selectedPithosAccount.syncDirectoryPath isEqualToString:syncDirectoryPath] && 
                               (![[NSFileManager defaultManager] fileExistsAtPath:syncDirectoryPath isDirectory:&isDirectory] || 
                                isDirectory)) ||
                              ![selectedPithosAccount.syncAccountsDictionary isEqualToDictionary:syncAccountsDictionary]));
     self.syncCancelEnable = (selectedPithosAccount.active && 
                              ((selectedPithosAccount.syncActive != syncActive) || 
+                              (selectedPithosAccount.syncSkipHidden != syncSkipHidden) || 
                               ![selectedPithosAccount.syncDirectoryPath isEqualToString:syncDirectoryPath] ||
                               ![selectedPithosAccount.syncAccountsDictionary isEqualToDictionary:syncAccountsDictionary]));
 }
     [self updateSync];
 }
 
+- (void)setSyncSkipHidden:(BOOL)aSyncSkipHidden {
+    syncSkipHidden = aSyncSkipHidden;
+    [self updateSync];
+    [self selectedPithosAccountNodeChildrenUpdated:nil];
+}
+
 - (void)setSyncDirectoryPath:(NSString *)aSyncDirectoryPath {
     [syncDirectoryPath release];
     syncDirectoryPath = [aSyncDirectoryPath copy];
 - (IBAction)syncApply:(id)sender {
     [selectedPithosAccount updateSyncWithSyncActive:syncActive 
                                   syncDirectoryPath:syncDirectoryPath 
-                           syncAccountsDictionary:syncAccountsDictionary];
+                           syncAccountsDictionary:syncAccountsDictionary 
+                                     syncSkipHidden:syncSkipHidden];
     [self updateSync];
     pithos_macosAppDelegate *delegate = (pithos_macosAppDelegate *)[[NSApplication sharedApplication] delegate];
     [delegate savePithosAccounts:self];
     self.syncDirectoryPath = selectedPithosAccount.syncDirectoryPath;
     self.syncAccountsDictionary = selectedPithosAccount.syncAccountsDictionary;
     self.syncAccountsRootFilesNodes = [NSMutableDictionary dictionary];
-    [self selectedPithosAccountNodeChildrenUpdated:nil];
+    self.syncSkipHidden = selectedPithosAccount.syncSkipHidden;
 }
 
 - (IBAction)syncRefresh:(id)sender {
                 // We add 1 for the root files node
                 NSInteger subdirCount = 1;
                 for (PithosNode *node in containerNode.children) {
-                    if ([node class] == [PithosSubdirNode class])
+                    if (([node class] == [PithosSubdirNode class]) && (!syncSkipHidden || ![node.displayName hasPrefix:@"."]))
                         subdirCount++;
                 }
                 return subdirCount;
             PithosContainerNode *containerNode = (PithosContainerNode *)item;
             NSInteger currentSubdirIndex = -1;
             for (PithosNode *node in containerNode.children) {
-                if ([node class] == [PithosSubdirNode class]) {
+                if (([node class] == [PithosSubdirNode class]) && (!syncSkipHidden || ![node.displayName hasPrefix:@"."])) {
                     currentSubdirIndex++;
                     if (currentSubdirIndex == index)
                         return node;
                         }
                         NSMutableSet *newContainerExcludeDirectories = [NSMutableSet setWithObject:@""];
                         for (PithosNode *siblingNode in node.parent.children) {
-                            if ([siblingNode class] == [PithosSubdirNode class]) {
+                            if (([siblingNode class] == [PithosSubdirNode class]) && 
+                                (!syncSkipHidden || ![siblingNode.displayName hasPrefix:@"."])) {
                                 NSString *siblingDirectoryName = [[siblingNode.displayName lowercaseString] 
                                                                   stringByReplacingOccurrencesOfString:@"/" withString:@":"];
                                 if (![siblingDirectoryName isEqualToString:directoryName] && 
                         }
                         NSMutableSet *newContainerExcludeDirectories = [NSMutableSet set];
                         for (PithosNode *siblingNode in node.parent.children) {
-                            if ([siblingNode class] == [PithosSubdirNode class]) {
+                            if (([siblingNode class] == [PithosSubdirNode class]) && 
+                                (!syncSkipHidden || ![siblingNode.displayName hasPrefix:@"."])) {
                                 NSString *siblingDirectoryName = [[siblingNode.displayName lowercaseString] 
                                                                   stringByReplacingOccurrencesOfString:@"/" withString:@":"];
                                 if (![newContainerExcludeDirectories containsObject:siblingDirectoryName])