/// <summary> /// Creates instance of this class. /// </summary> /// <param name="syncIntervalMs">Synchronization interval in milliseconds.</param> /// <param name="userFileSystemRootPath">User file system root path.</param> /// <param name="log">Logger.</param> internal FullSyncService(double syncIntervalMs, string userFileSystemRootPath, VirtualDriveBase virtualDrive, ILog log) : base("Sync Service", log) { timer = new System.Timers.Timer(syncIntervalMs); timer.Elapsed += Timer_ElapsedAsync; this.userFileSystemRootPath = userFileSystemRootPath; this.virtualDrive = virtualDrive; }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="userFileSystemPath">File or folder path in user file system.</param> /// <param name="logger">Logger.</param> public UserFileSystemRawItem(string userFileSystemPath, VirtualDriveBase virtualDrive, ILogger logger) { if (string.IsNullOrEmpty(userFileSystemPath)) { throw new ArgumentNullException(nameof(userFileSystemPath)); } this.virtualDrive = virtualDrive ?? throw new ArgumentNullException(nameof(virtualDrive)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.userFileSystemPath = userFileSystemPath; this.eTagManager = virtualDrive.GetETagManager(userFileSystemPath); }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="userFileSystemPath">File or folder path in the user file system.</param> /// <param name="logger">Logger.</param> internal RemoteStorageRawItem(string userFileSystemPath, VirtualDriveBase virtualDrive, ILogger logger) { if (string.IsNullOrEmpty(userFileSystemPath)) { throw new ArgumentNullException(nameof(userFileSystemPath)); } this.virtualDrive = virtualDrive ?? throw new ArgumentNullException(nameof(virtualDrive)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.userFileSystemPath = userFileSystemPath; this.lockManager = virtualDrive.LockManager(userFileSystemPath, logger); this.userFileSystemRawItem = virtualDrive.GetUserFileSystemRawItem(userFileSystemPath, logger); }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="userFileSystemRootPath">User file system root path. Attributes are monitored in this folder.</param> /// <param name="log">Logger.</param> internal UserFileSystemMonitor(string userFileSystemRootPath, VirtualDriveBase virtualDrive, ILog log) : base("User File System Monitor", log) { this.virtualDrive = virtualDrive; watcher.IncludeSubdirectories = true; watcher.Path = userFileSystemRootPath; //watcher.Filter = "*.*"; watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.FileName | NotifyFilters.DirectoryName; watcher.Error += Error; watcher.Created += CreatedAsync; watcher.Changed += ChangedAsync; watcher.Deleted += DeletedAsync; watcher.Renamed += RenamedAsync; }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="userFileSystemPath">File or folder path in the user file system.</param> /// <param name="logger">Logger.</param> internal RemoteStorageRawItem(string userFileSystemPath, VirtualDriveBase virtualDrive, ILogger logger) { if (string.IsNullOrEmpty(userFileSystemPath)) { throw new ArgumentNullException("userFileSystemPath"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.userFileSystemPath = userFileSystemPath; this.virtualDrive = virtualDrive; this.logger = logger; }
/// <summary> /// Creates a new file or folder in the remote storage. /// </summary> /// <param name="userFileSystemNewItemPath">Path to the file or folder in the user file system to be created in the remote storage.</param> /// <param name="logger">Logger</param> public static async Task CreateAsync(string userFileSystemNewItemPath, VirtualDriveBase userEngine, ILogger logger) { try { logger.LogMessage("Creating item in the remote storage", userFileSystemNewItemPath); await new RemoteStorageRawItem(userFileSystemNewItemPath, userEngine, logger).CreateOrUpdateAsync(FileMode.CreateNew); await new UserFileSystemRawItem(userFileSystemNewItemPath).ClearStateAsync(); logger.LogMessage("Created in the remote storage succesefully", userFileSystemNewItemPath); } catch (Exception ex) { await new UserFileSystemRawItem(userFileSystemNewItemPath).SetUploadErrorStateAsync(ex); // Rethrow the exception preserving stack trace of the original exception. System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw(); } }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="virtualDrive"><see cref="VirtualDriveBase"/> instance.</param> /// <param name="log">Logger.</param> internal ServerToClientSync(VirtualDriveBase virtualDrive, ILog log) : base("UFS <- RS Sync", log) { this.virtualDrive = virtualDrive; }
/// <summary> /// Creates instance of this class. /// </summary> /// <param name="log">Logger.</param> internal ClientToServerSync(VirtualDriveBase virtualDrive, ILog log) : base("UFS -> RS Sync", log) { this.virtualDrive = virtualDrive; }