/// <summary> /// Called when the initial file system scan completes. /// </summary> /// <param name="scan">The scan object</param> /// <param name="e">Exception that was raised if the scan failed, null on success.</param> public void OnInitialScanCompleted(KfsScan scan, bool success, Exception e) { Logging.Log("Initial scan finished."); Debug.Assert(ScanRunningFlag); Debug.Assert(InitialScanStatus != InitScanStatus.OK); InitialScanDate = DateTime.Now; ScanRunningFlag = false; if (success) { // If the status != none, it means the FSWatcher encountered an error. // The initial scan is NOT completed and must be run again. Otherwise, // synchronize the results. if (InitialScanStatus == InitScanStatus.None) { InitialScanStatus = InitScanStatus.OK; RequestStatusViewUpdate("InitialScan completed with success"); scan.Sync(); } } else { OnScanFailed(); DisallowUserOp("initial scan failed", AllowedOpStatus.None); if (e != null) { Logging.Log("Initial scan failed : " + e.Message + "."); Logging.LogException(e); } } Pipeline.Run("initial scan completed", true); }
/// <summary> /// This method contains the code that has to be executed both on /// deserialization and on construction of this object. This method /// should not throw an exception. /// </summary> public void Initialize() { String shareRoot; if (Misc.ApplicationSettings.KfsStorePath == "") shareRoot = Misc.GetKfsDefaultStorePath(); else shareRoot = Misc.ApplicationSettings.KfsStorePath; SharePath = Path.Combine(shareRoot, App.Helper.GetKwsUniqueName()) + "\\"; InitialScanStatus = InitScanStatus.None; InitialScanDate = DateTime.MinValue; StaleFsEventDate = DateTime.MinValue; PartialScanDate = DateTime.MinValue; ScanRunningFlag = false; ServerOpAppDate = DateTime.MinValue; ServerOpRunningFlag = false; LocalUpdateFlag = true; LocalUpdateDate = DateTime.MinValue; ActiveFlag = false; StatusViewStaleDate = DateTime.MinValue; UpdateStatusViewFlag = false; TypeConflictFlag = false; ReportErrorToUserFlag = false; AllowedOp = InitialAllowedOp = AllowedOpStatus.None; TransferOrderID = 1; FileTransferTree = new SortedDictionary<String, UInt32>(); TransferErrorArray = new List<KfsTransferError>(); new KfsStatusView(this); new KfsPipeline(this); new KfsGate(this); new KfsDownloadManager(this); new KfsUploadManager(this); new KfsMetaDataManager(this); m_phase1Events = new SortedDictionary<UInt64, List<KfsServerOp>>(); }
/// <summary> /// This method must be called if any scan failed. /// </summary> private void OnScanFailed() { // The watcher might have failed on us before we finished the scan. // In that case, the watcher has already been disabled. if (InitialScanStatus != InitScanStatus.Fail) { InitialScanStatus = InitScanStatus.Fail; StopWatcher(); } }
/// <summary> /// This method is called to stop the share. It returns true when the /// share is ready to stop. /// </summary> public bool TryStop() { // Eventually make the scanner thread cancellable. StopWatcher(); CancelAllNetworkOperations(); InitialScanStatus = InitScanStatus.None; ReportErrorToUserFlag = false; AllowedOp = AllowedOpStatus.None; InitialAllowedOp = AllowedOpStatus.None; return (Gate.EntryCount == 0 && !ScanRunningFlag && DownloadManager.Status == DownloadManagerStatus.Idle && UploadManager.Status == UploadManagerStatus.Idle && MetaDataManager.Status == MetaDataManagerStatus.Idle); }
/// <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; }
/// <summary> /// This method contains the code that has to be executed both on /// deserialization and on construction of this object. This method /// should not throw an exception. /// </summary> public void Initialize() { m_licenseRestrictionError = false; InitialScanStatus = InitScanStatus.None; InitialScanDate = DateTime.MinValue; StaleFsEventDate = DateTime.MinValue; PartialScanDate = DateTime.MinValue; ScanRunningFlag = false; ServerOpAppDate = DateTime.MinValue; ServerOpRunningFlag = false; LocalUpdateFlag = true; LocalUpdateDate = DateTime.MinValue; ActiveFlag = false; StatusViewStaleDate = DateTime.MinValue; UpdateStatusViewFlag = false; TypeConflictFlag = false; ReportErrorToUserFlag = false; AllowedOp = InitialAllowedOp = AllowedOpStatus.None; TransferOrderID = 1; FileTransferTree = new SortedDictionary<String, UInt32>(KfsPath.Comparer); TransferErrorArray = new List<KfsTransferError>(); new KfsStatusView(this); new KfsPipeline(this); new KfsGate(this); new KfsDownloadManager(this); new KfsUploadManager(this); new KfsMetaDataManager(this); m_phase1Events = new SortedDictionary<UInt64, List<KfsServerOp>>(); }