Revision 1cc1e8c5 trunk/Pithos.Core/Agents/SelectiveUris.cs

b/trunk/Pithos.Core/Agents/SelectiveUris.cs
65 65
            SelectivePaths[account.AccountKey] = UrisToFilePaths(account,uris);
66 66
        }
67 67

  
68
        public void AddUri(AccountInfo account,Uri uri)
69
        {
70
            var accountPath = account.AccountPath;
71
            var storageUrl = account.StorageUri.ToString();
72
            var isShared=!uri.ToString().StartsWith(storageUrl);
73
            var relativePath = account.StorageUri.MakeRelativeUri(uri).RelativeUriToFilePath();
74
            
75
            var fullPath=isShared
76
                ?Path.Combine(accountPath, FolderConstants.OthersFolder, relativePath)
77
                :Path.Combine(accountPath, relativePath.After(account.UserName + '\\'));
78
            
79
            SelectiveUris[account.AccountKey].Add(uri);
80
            SelectivePaths[account.AccountKey].Add(fullPath);
81
            
82
        }
83

  
68 84
        public bool IsSelected(AccountInfo account,ObjectInfo info)
69 85
        {
70 86
            //Shared folders should NOT be synced if selective syncing is disabled
......
97 113
                return !isShared;
98 114

  
99 115
            List<string> paths;
100
            return !SelectivePaths.TryGetValue(account.AccountKey, out paths)
101
                || paths.Count == 0
102
                || paths.Any(fullPath.IsAtOrDirectlyBelow);
116
            var hasSelectives = SelectivePaths.TryGetValue(account.AccountKey, out paths);
117
            var isSelected = !hasSelectives || paths.Count == 0 || paths.Any(fullPath.IsAtOrDirectlyBelow);
118
            return isSelected;
103 119
        }
104 120

  
105 121
        /// <summary>
......
123 139
                          where !uri.ToString().StartsWith(storageUrl)
124 140
                          let relativePath = account.StorageUri.MakeRelativeUri(uri).RelativeUriToFilePath()
125 141
                          //Trim the account name
126
                          select Path.Combine(accountPath, "others-shared", relativePath)).ToList();
142
                          select Path.Combine(accountPath, FolderConstants.OthersFolder, relativePath)).ToList();
127 143
            return own.Union(others).ToList();
128 144
        }
129 145

  

Also available in: Unified diff