///<inheritdoc> public async Task DeleteAsync(IOperationContext operationContext, IConfirmationResultContext resultContext) { /* * Logger.LogMessage($"{nameof(IFileSystemItem)}.{nameof(DeleteAsync)}()", this.UserFileSystemPath); * string userFileSystemPath = this.UserFileSystemPath; * Logger.LogMessage("Confirming delete in user file system", userFileSystemPath); * resultContext.ReturnConfirmationResult(); */ Logger.LogMessage("IFileSystemItem.DeleteAsync()", this.UserFileSystemPath); string userFileSystemPath = this.UserFileSystemPath; string remoteStoragePath = null; try { if (Engine.ChangesProcessingEnabled && !FsPath.AvoidSync(userFileSystemPath)) { await new RemoteStorageRawItem <TItemType>(userFileSystemPath, VirtualDrive, Logger).DeleteAsync(); Logger.LogMessage("Deleted item in remote storage succesefully", userFileSystemPath); } } catch (Exception ex) { Logger.LogError("Delete failed", remoteStoragePath, null, ex); } finally { resultContext.ReturnConfirmationResult(); } }
/// <inheritdoc/> public async Task CloseAsync(IOperationContext operationContext, IResultContext context) { // Here, if the file in the user file system is modified (not in-sync), you will send the file content, // creation time, modification time and attributes to the remote storage. // We also send ETag, to make sure the changes on the server, if any, are not overwritten. Logger.LogMessage("IFile.CloseAsync()", UserFileSystemPath); string userFileSystemFilePath = UserFileSystemPath; // In case the file is moved it does not exist in user file system when CloseAsync() is called. if (Engine.ChangesProcessingEnabled && FsPath.Exists(userFileSystemFilePath) && !FsPath.AvoidSync(userFileSystemFilePath)) { // In case the file is overwritten it is converted to a regular file prior to CloseAsync(). // we need to convert it back into file/folder placeholder. if (!PlaceholderItem.IsPlaceholder(userFileSystemFilePath)) { PlaceholderItem.ConvertToPlaceholder(userFileSystemFilePath, false); Logger.LogMessage("Converted to placeholder", userFileSystemFilePath); } try { if (PlaceholderItem.GetItem(userFileSystemFilePath).IsNew(VirtualDrive)) { // Create new file in the remote storage. await new RemoteStorageRawItem <IVirtualFile>(userFileSystemFilePath, VirtualDrive, Logger).CreateAsync(); } else if (!PlaceholderItem.GetItem(userFileSystemFilePath).IsMoved()) { // Send content to remote storage. Unlock if auto-locked. await new RemoteStorageRawItem <IVirtualFile>(userFileSystemFilePath, VirtualDrive, Logger).UpdateAsync(); } } catch (IOException ex) { // Either the file is already being synced in another thread or client or server file is blocked by concurrent process. // This is a normal behaviour. // The file must be synched by your synchronyzation service at a later time, when the file becomes available. Logger.LogMessage("Failed to upload file. Possibly in use by an application or blocked for synchronization in another thread:", ex.Message); } } }