Revision d9b1cbeb trunk/Pithos.Core/Agents/FileAgent.cs

b/trunk/Pithos.Core/Agents/FileAgent.cs
205 205

  
206 206
        private bool Ignore(string filePath)
207 207
        {
208
            var pithosPath = Path.Combine(RootPath, "pithos");
209
            if (pithosPath.Equals(filePath, StringComparison.InvariantCultureIgnoreCase))
210
                return true;
208
            //Ignore all first-level directories and files            
209
            if (FoundBelowRoot(filePath, RootPath,1))
210
                return true;            
211

  
212
            //Ignore first-level items under the "others" folder.
213
            var othersPath = Path.Combine(RootPath, FolderConstants.OthersFolder);
214
            if (FoundBelowRoot(filePath, othersPath,1))
215
                return true;            
216

  
217
            //Ignore second-level (container) folders under the "others" folder. 
218
            if (FoundBelowRoot(filePath, othersPath,2))
219
                return true;            
220

  
221

  
222
            //Ignore anything happening in the cache path
211 223
            if (filePath.StartsWith(CachePath))
212 224
                return true;
213 225
            if (_ignoreFiles.ContainsKey(filePath.ToLower()))
......
215 227
            return false;
216 228
        }
217 229

  
230
/*        private static bool FoundInRoot(string filePath, string rootPath)
231
        {
232
            //var rootDirectory = new DirectoryInfo(rootPath);
233

  
234
            //If the paths are equal, return true
235
            if (filePath.Equals(rootPath, StringComparison.InvariantCultureIgnoreCase))
236
                return true;
237

  
238
            //If the filepath is below the root path
239
            if (filePath.StartsWith(rootPath,StringComparison.InvariantCulture))
240
            {
241
                //Get the relative path
242
                var relativePath = filePath.Substring(rootPath.Length + 1);
243
                //If the relativePath does NOT contains a path separator, we found a match
244
                return (!relativePath.Contains(@"\"));
245
            }
246

  
247
            //If the filepath is not under the root path, return false
248
            return false;            
249
        }*/
250

  
251

  
252
        private static bool FoundBelowRoot(string filePath, string rootPath,int level)
253
        {
254
            //var rootDirectory = new DirectoryInfo(rootPath);
255

  
256
            //If the paths are equal, return true
257
            if (filePath.Equals(rootPath, StringComparison.InvariantCultureIgnoreCase))
258
                return true;
259

  
260
            //If the filepath is below the root path
261
            if (filePath.StartsWith(rootPath,StringComparison.InvariantCulture))
262
            {
263
                //Get the relative path
264
                var relativePath = filePath.Substring(rootPath.Length + 1);
265
                //If the relativePath does NOT contains a path separator, we found a match
266
                var levels=relativePath.ToCharArray().Count(c=>c=='\\')+1;                
267
                return levels==level;
268
            }
269

  
270
            //If the filepath is not under the root path, return false
271
            return false;            
272
        }
273

  
218 274
        //Post a Change message for all events except rename
219 275
        void OnFileEvent(object sender, FileSystemEventArgs e)
220 276
        {

Also available in: Unified diff