Revision 5120f3cb trunk/Pithos.Core/PithosMonitor.cs

b/trunk/Pithos.Core/PithosMonitor.cs
18 18
using Pithos.Interfaces;
19 19
using System.ServiceModel;
20 20
using Pithos.Network;
21
using log4net;
21 22

  
22 23
namespace Pithos.Core
23 24
{
......
61 62

  
62 63
        private ServiceHost _statusService { get; set; }
63 64

  
65
        private static readonly ILog Log = LogManager.GetLogger(typeof(PithosMonitor));
66

  
64 67

  
65 68
        public bool Pause
66 69
        {
......
182 185
        private void IndexLocalFiles(string path)
183 186
        {
184 187
            StatusNotification.NotifyChange("Indexing Local Files",TraceLevel.Info);
185
            Trace.TraceInformation("[START] Index Local");
186
            try
188
            using (log4net.ThreadContext.Stacks["Monitor"].Push("Indexing local files"))
187 189
            {
188
                var fragmentsPath=Path.Combine(RootPath, FragmentsFolder);
189
                var directory = new DirectoryInfo(path);
190
                var files =
191
                    from file in directory.EnumerateFiles("*", SearchOption.AllDirectories)
192
                    where !file.FullName.StartsWith(fragmentsPath,StringComparison.InvariantCultureIgnoreCase) &&
193
                            !file.Extension.Equals("ignore",StringComparison.InvariantCultureIgnoreCase)
194
                    select file;
195
                StatusKeeper.ProcessExistingFiles(files);
196
                
197
            }
198
            catch (Exception exc)
199
            {
200
                Trace.TraceError("[ERROR] Index Local - {0}", exc);
201
            }
202
            finally
203
            {
204
                Trace.TraceInformation("[END] Inxed Local");
190
                Log.Info("START");
191
                try
192
                {
193
                    var fragmentsPath = Path.Combine(RootPath, FragmentsFolder);
194
                    var directory = new DirectoryInfo(path);
195
                    var files =
196
                        from file in directory.EnumerateFiles("*", SearchOption.AllDirectories)
197
                        where !file.FullName.StartsWith(fragmentsPath, StringComparison.InvariantCultureIgnoreCase) &&
198
                              !file.Extension.Equals("ignore", StringComparison.InvariantCultureIgnoreCase)
199
                        select file;
200
                    StatusKeeper.ProcessExistingFiles(files);
201

  
202
                }
203
                catch (Exception exc)
204
                {
205
                    Log.Error("[ERROR]", exc);
206
                }
207
                finally
208
                {
209
                    Log.Info("[END]");
210
                }
205 211
            }
206 212
        }
207 213

  
......
341 347
                var info = Directory.CreateDirectory(folder);
342 348
                info.Attributes |= FileAttributes.Hidden;
343 349

  
344
                Trace.TraceInformation("Created Fragments Folder: {0}", folder);
350
                Log.InfoFormat("Created Fragments Folder: {0}", folder);
345 351
            }
346 352
            return folder;
347 353
        }
......
387 393
        }
388 394

  
389 395

  
396
        public void MoveFileStates(string oldPath, string newPath)
397
        {
398
            if (String.IsNullOrWhiteSpace(oldPath))
399
                throw new ArgumentNullException("oldPath");
400
            if (!Path.IsPathRooted(oldPath))
401
                throw new ArgumentException("oldPath must be an absolute path","oldPath");
402
            if (string.IsNullOrWhiteSpace(newPath))
403
                throw new ArgumentNullException("newPath");
404
            if (!Path.IsPathRooted(newPath))
405
                throw new ArgumentException("newPath must be an absolute path","newPath");
406
            Contract.EndContractBlock();
407

  
408
            StatusKeeper.ChangeRoots(oldPath, newPath);
409
        }
390 410
    }
391 411

  
392 412
    public interface IStatusNotification

Also available in: Unified diff