Beispiel #1
0
        /// <summary>
        /// Perform the initial scan of the share. This method returns true
        /// if the initial scan could be started.
        /// </summary>
        public bool StartInitialScan()
        {
            Logging.Log("Doing initial scan.");

            Debug.Assert(!ScanRunningFlag);
            Debug.Assert(InitialScanStatus != InitScanStatus.OK);
            Debug.Assert(FsWatcher == null);
            InitialScanStatus = InitScanStatus.None;

            // Try to start the watcher.
            try
            {
                // Create the share directory if it does not exist.
                if (!Directory.Exists(ShareFullPath)) Directory.CreateDirectory(ShareFullPath);
                StaleFsEventDate = DateTime.MinValue;
                FsWatcher = new KfsFsWatcher(this);
                StaleTree = new KfsStaleTree(null);
            }

            catch (Exception ex)
            {
                Logging.Log(2, "Failed to start file system watcher: " + ex.Message + ".");
                OnScanFailed();
                InitialScanDate = DateTime.Now;
                return false;
            }

            // Try to start the thread.
            try
            {
                ScanRunningFlag = true;
                KfsInitialScanThread scanner = new KfsInitialScanThread(this);
                scanner.Start();
            }

            catch (Exception e)
            {
                Base.HandleException(e, true);
            }

            return true;
        }
Beispiel #2
0
 /// <summary>
 /// Stop the watcher if it is running.
 /// </summary>
 public void StopWatcher()
 {
     if (FsWatcher != null)
     {
         FsWatcher.StopWatching();
         FsWatcher = null;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Stop the watcher if it is running.
 /// </summary>
 public void StopWatcher()
 {
     try
     {
         Logging.Log("StopWatcher() called.");
         if (FsWatcher != null)
         {
             FsWatcher.StopWatching();
             FsWatcher = null;
         }
     }
     catch (Exception ex)
     {
         Logging.LogException(ex);
         Base.HandleException(ex, true);
     }
 }