From 5668f5085e4c088d639b8d7da7fbbac5f841cc06 Mon Sep 17 00:00:00 2001 From: IT Hit Date: Tue, 17 Dec 2024 13:04:18 +0200 Subject: [PATCH] v8.4.27341.0 --- Common/Common.csproj | 4 +- Windows/Common/Core/Commands.cs | 21 --- .../Common/Core/Common.Windows.Core.csproj | 12 +- Windows/Common/Core/LogFormatter.cs | 1 + .../Common.Windows.VirtualDrive.csproj | 6 +- .../VirtualDrive.Package.wapproj | 3 +- .../VirtualDrive/VirtualDrive.csproj | 12 +- .../VirtualFileSystem.csproj | 6 +- .../Pages/MountNewDrivePage.xaml.cs | 18 +- .../RemoteStorageMonitorCRUDE.cs | 161 ------------------ .../WebDAVDrive/Services/DomainsService.cs | 1 + .../Utils/ProtocolParametersUtil.cs | 2 +- .../WebDAVDrive/WebDAVDrive.csproj | 21 ++- 13 files changed, 46 insertions(+), 222 deletions(-) delete mode 100644 Windows/WebDAVDrive/WebDAVDrive/RemoteStorageMonitor/RemoteStorageMonitorCRUDE.cs diff --git a/Common/Common.csproj b/Common/Common.csproj index 5be5924..eb128c5 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -10,7 +10,7 @@ AnyCPU;x64 - - + + \ No newline at end of file diff --git a/Windows/Common/Core/Commands.cs b/Windows/Common/Core/Commands.cs index 36912c1..c06cbda 100644 --- a/Windows/Common/Core/Commands.cs +++ b/Windows/Common/Core/Commands.cs @@ -199,26 +199,5 @@ public void ShowTestEnvironment(string userFileSystemWindowName, bool openRemote } #endif - - public void Test() - { - string name = "Notes.txt"; - string filePath = Path.Combine(Engine.Path, name); - //FileInfo fi = new FileInfo(filePath); - //fi.IsReadOnly = true; - - var n = Engine.ServerNotifications(filePath); - IFileMetadata metadata = new FileMetadata(); - metadata.Attributes = FileAttributes.Normal; - metadata.CreationTime = DateTimeOffset.Now; - metadata.LastWriteTime = DateTimeOffset.Now; - metadata.ChangeTime = DateTimeOffset.Now; - metadata.LastAccessTime = DateTimeOffset.Now; - metadata.Name = name; - metadata.MetadataETag = DateTimeOffset.Now.Ticks.ToString(); - metadata.ContentETag = null;//"etag1"; - n.UpdateAsync(metadata); - } - } } diff --git a/Windows/Common/Core/Common.Windows.Core.csproj b/Windows/Common/Core/Common.Windows.Core.csproj index 8b39c7d..a5a6266 100644 --- a/Windows/Common/Core/Common.Windows.Core.csproj +++ b/Windows/Common/Core/Common.Windows.Core.csproj @@ -1,6 +1,6 @@ - net8.0-windows10.0.19041.0;net48 + net9.0-windows10.0.19041.0;net48 True Contains functionality common for all Windows Virtual Drive samples. IT Hit LTD. @@ -16,15 +16,15 @@ - - + + - + - - + + \ No newline at end of file diff --git a/Windows/Common/Core/LogFormatter.cs b/Windows/Common/Core/LogFormatter.cs index 1465e03..70dab77 100644 --- a/Windows/Common/Core/LogFormatter.cs +++ b/Windows/Common/Core/LogFormatter.cs @@ -141,6 +141,7 @@ public async Task PrintEngineDescriptionAsync(EngineWindows engine, string remot Log.Info($"\n{"Shell extensions RPC enabled:",indent} {engine.ShellExtensionsComServerRpcEnabled}"); Log.Info($"\n{"Max create/read/write concurrent requests:",indent} {engine.MaxTransferConcurrentRequests}"); Log.Info($"\n{"Max list/move/delete concurrent requests:",indent} {engine.MaxOperationsConcurrentRequests}"); + Log.Info($"\n{"Folder invalidation interval, ms:",indent} {engine.FolderInvalidationIntervalMs}"); // Log indexing state. Sync root must be indexed. await PrintIndexingStateAsync(engine.Path); diff --git a/Windows/Common/VirtualDrive/Common.Windows.VirtualDrive.csproj b/Windows/Common/VirtualDrive/Common.Windows.VirtualDrive.csproj index 51644ad..a521604 100644 --- a/Windows/Common/VirtualDrive/Common.Windows.VirtualDrive.csproj +++ b/Windows/Common/VirtualDrive/Common.Windows.VirtualDrive.csproj @@ -1,6 +1,6 @@ - net8.0-windows10.0.19041.0 + net9.0-windows10.0.19041.0 Contains functionality common for all Windows Virtual Drive samples. IT Hit LTD. IT Hit User File System @@ -13,8 +13,8 @@ - - + + diff --git a/Windows/VirtualDrive/VirtualDrive.Package/VirtualDrive.Package.wapproj b/Windows/VirtualDrive/VirtualDrive.Package/VirtualDrive.Package.wapproj index 53479cf..cb9597e 100644 --- a/Windows/VirtualDrive/VirtualDrive.Package/VirtualDrive.Package.wapproj +++ b/Windows/VirtualDrive/VirtualDrive.Package/VirtualDrive.Package.wapproj @@ -65,7 +65,8 @@ - + + diff --git a/Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj b/Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj index aaaccd7..cc6ba7b 100644 --- a/Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj +++ b/Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj @@ -1,7 +1,7 @@ Exe - net8.0-windows10.0.19041.0 + net9.0-windows10.0.19041.0 IT Hit LTD. IT Hit LTD. Virtual Drive @@ -35,12 +35,12 @@ This is an advanced project with ETags support, Microsoft Office documents editi - - - + + + - + @@ -83,6 +83,6 @@ This is an advanced project with ETags support, Microsoft Office documents editi - + \ No newline at end of file diff --git a/Windows/VirtualFileSystem/VirtualFileSystem.csproj b/Windows/VirtualFileSystem/VirtualFileSystem.csproj index 91e94e7..d292099 100644 --- a/Windows/VirtualFileSystem/VirtualFileSystem.csproj +++ b/Windows/VirtualFileSystem/VirtualFileSystem.csproj @@ -1,7 +1,7 @@ Exe - net8.0-windows10.0.19041.0 + net9.0-windows10.0.19041.0 IT Hit LTD. IT Hit LTD. Virtual File System @@ -32,10 +32,10 @@ This project does not support ETags, locking, Microsoft Office documents editing - + - + diff --git a/Windows/WebDAVDrive/WebDAVDrive/Pages/MountNewDrivePage.xaml.cs b/Windows/WebDAVDrive/WebDAVDrive/Pages/MountNewDrivePage.xaml.cs index acf486c..59bc84c 100644 --- a/Windows/WebDAVDrive/WebDAVDrive/Pages/MountNewDrivePage.xaml.cs +++ b/Windows/WebDAVDrive/WebDAVDrive/Pages/MountNewDrivePage.xaml.cs @@ -6,10 +6,10 @@ namespace WebDAVDrive; public partial class MountNewDrivePage : ContentPage { - public MountNewDrivePage() - { - InitializeComponent(); - } + public MountNewDrivePage() + { + InitializeComponent(); + } private async void OnValidateClicked(object sender, EventArgs e) { @@ -34,14 +34,18 @@ private async void OnValidateClicked(object sender, EventArgs e) btnAddDrive.IsEnabled = false; // Mount new domain. - await ServiceProviderUtil.GetService().MountNewAsync([url]); + _ = Task.Run(async () => + { + await ServiceProviderUtil.GetService().MountNewAsync([url]); + + }); Application.Current.CloseWindow(Window); } else - { + { ValidationMessage.Text = "Invalid URL. Please enter a valid URL."; ValidationMessage.IsVisible = true; - } + } } } diff --git a/Windows/WebDAVDrive/WebDAVDrive/RemoteStorageMonitor/RemoteStorageMonitorCRUDE.cs b/Windows/WebDAVDrive/WebDAVDrive/RemoteStorageMonitor/RemoteStorageMonitorCRUDE.cs deleted file mode 100644 index 7d5464b..0000000 --- a/Windows/WebDAVDrive/WebDAVDrive/RemoteStorageMonitor/RemoteStorageMonitorCRUDE.cs +++ /dev/null @@ -1,161 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using ITHit.FileSystem; -using ITHit.FileSystem.Samples.Common.Windows; -using ITHit.FileSystem.Synchronization; -using ITHit.FileSystem.Windows; -using ITHit.WebDAV.Client; - - -namespace WebDAVDrive -{ - /// - /// Monitors changes in the remote storage, notifies the client and updates the user file system. - /// - /// - /// This monitor receives messages about files being created, updated, deleted and moved. - /// It also performs a complete synchronization via poolin using a - /// call on application start and web sockets reconnection. - /// - /// If any item changed in the remote storage it calls interfce methods. - /// - internal class RemoteStorageMonitorCRUDE : RemoteStorageMonitorBase - { - /// - /// Sync mode that corresponds with this remote storage monitor type; - /// - public override IncomingSyncMode SyncMode { get { return IncomingSyncMode.Disabled; } } - - /// - /// instance. - /// - private readonly VirtualEngine engine; - - private readonly string webDAVServerUrl; - - internal RemoteStorageMonitorCRUDE(string webSocketServerUrl, string webDAVServerUrl, VirtualEngine engine) - : base(webSocketServerUrl, int.MinValue, engine.Logger.CreateLogger($"RS Monitor: CRUDE")) - { - this.webDAVServerUrl = webDAVServerUrl; - this.engine = engine; - } - - /// - public override bool Filter(WebSocketMessage webSocketMessage) - { - string remoteStoragePath = engine.Mapping.GetAbsoluteUri(webSocketMessage.ItemPath); - - // Just in case there is more than one WebSockets server/virtual folder that - // is sending notifications (like with webdavserver.net, webdavserver.com), - // here we filter notifications that come from a different server/virtual folder. - if (remoteStoragePath.StartsWith(webDAVServerUrl, StringComparison.InvariantCultureIgnoreCase)) - { - Logger.LogDebug($"EventType: {webSocketMessage.EventType}", webSocketMessage.ItemPath, webSocketMessage.TargetPath); - return false; - } - - return true; - } - - /// - /// Triggers call to get - /// and process all changes from the remote storage. - /// - /// Information about changes or null in case of Engine start or sockets reconnection. - /// - /// We do not pass WebSockets cancellation token to this method because stopping - /// web sockets should not stop processing changes. - /// To stop processing changes that are already received the Engine must be stopped. - /// - protected override async Task ProcessAsync(WebSocketMessage webSocketMessage = null) - { - if(webSocketMessage == null) - { - // This is the Engine start, sockets reconnection or authentication event. - // Performing full sync of loaded items using pooling. - await engine.SyncService.IncomingPooling.ProcessAsync(); - } - else - { - // The item is created, updated, moved or deleted. - // Updating a single item. - await ProcessWebSocketsMessageAsync(webSocketMessage); - } - } - - protected async Task ProcessWebSocketsMessageAsync(WebSocketMessage webSocketMessage) - { - try - { - string remoteStoragePath = engine.Mapping.GetAbsoluteUri(webSocketMessage.ItemPath); - - string userFileSystemPath = engine.Mapping.ReverseMapPath(remoteStoragePath); - var cancellationToken = engine.CancellationTokenSource.Token; - switch (webSocketMessage.EventType) - { - case "created": - await CreateAsync(remoteStoragePath); - break; - - case "updated": - case "locked": - case "unlocked": - var resUpdate = await engine.DavClient.GetItemAsync(new Uri(remoteStoragePath), Mapping.GetDavProperties(), null, cancellationToken); - IHierarchyItem itemUpdate = resUpdate.WebDavResponse; - if (itemUpdate != null) - { - IFileSystemItemMetadata metadataUpdate = Mapping.GetUserFileSystemItemMetadata(itemUpdate); - await engine.ServerNotifications(userFileSystemPath).UpdateAsync(metadataUpdate); - } - break; - - case "deleted": - await engine.ServerNotifications(userFileSystemPath).DeleteAsync(); - break; - - case "moved": - string remoteStorageNewPath = engine.Mapping.GetAbsoluteUri(webSocketMessage.TargetPath); - string userFileSystemNewPath = engine.Mapping.ReverseMapPath(remoteStorageNewPath); - var res = await engine.ServerNotifications(userFileSystemPath).MoveToAsync(userFileSystemNewPath); - switch (res.Status) - { - case OperationStatus.NotFound: - // Source item is not loaded. Creating the item in the target folder. - await CreateAsync(remoteStorageNewPath); - break; - - case OperationStatus.TargetNotFound: - // The target parent folder does not exists or is offline, delete the source item. - await engine.ServerNotifications(userFileSystemPath).DeleteAsync(); - break; - } - - break; - } - } - catch (Exception ex) - { - Logger.LogError($"Failed to process:{webSocketMessage.EventType}", webSocketMessage.ItemPath, webSocketMessage.TargetPath, ex); - } - } - - private async Task CreateAsync(string remoteStoragePath) - { - var resCreate = await engine.DavClient.GetItemAsync(new Uri(remoteStoragePath), Mapping.GetDavProperties(), null, engine.CancellationTokenSource.Token); - IHierarchyItem itemCreate = resCreate.WebDavResponse; - if (itemCreate != null) - { - string userFileSystemPath = engine.Mapping.ReverseMapPath(remoteStoragePath); - string userFileSystemParentPath = Path.GetDirectoryName(userFileSystemPath); - - IFileSystemItemMetadata metadataCreate = Mapping.GetUserFileSystemItemMetadata(itemCreate); - await engine.ServerNotifications(userFileSystemParentPath).CreateAsync(new[] { metadataCreate }); - } - } - } -} diff --git a/Windows/WebDAVDrive/WebDAVDrive/Services/DomainsService.cs b/Windows/WebDAVDrive/WebDAVDrive/Services/DomainsService.cs index 488fafc..b085fcc 100644 --- a/Windows/WebDAVDrive/WebDAVDrive/Services/DomainsService.cs +++ b/Windows/WebDAVDrive/WebDAVDrive/Services/DomainsService.cs @@ -304,6 +304,7 @@ private async Task TryCreateEngineAsync(string webDAVServerUrl, string use engine.AutoLock = Settings.AutoLock; engine.MaxTransferConcurrentRequests = Settings.MaxTransferConcurrentRequests.Value; engine.MaxOperationsConcurrentRequests = Settings.MaxOperationsConcurrentRequests.Value; + engine.FolderInvalidationIntervalMs = Settings.FolderInvalidationIntervalMs; // Print Engine config, settings, logging headers. await LogFormatter.PrintEngineStartInfoAsync(engine, webDAVServerUrl); diff --git a/Windows/WebDAVDrive/WebDAVDrive/Utils/ProtocolParametersUtil.cs b/Windows/WebDAVDrive/WebDAVDrive/Utils/ProtocolParametersUtil.cs index 6204a6b..2c78da7 100644 --- a/Windows/WebDAVDrive/WebDAVDrive/Utils/ProtocolParametersUtil.cs +++ b/Windows/WebDAVDrive/WebDAVDrive/Utils/ProtocolParametersUtil.cs @@ -45,7 +45,7 @@ public static ProtocolParameters Parse(Uri uri) { ItemUrls = GetItemUrls(parameters), MountUrl = new Uri(HttpUtility.UrlDecode(parameters["MountUrl"])), - Command = Enum.TryParse(HttpUtility.UrlDecode(parameters["Command"]), true, out CommandType command) + Command = parameters.ContainsKey("Command") && Enum.TryParse(HttpUtility.UrlDecode(parameters["Command"]), true, out CommandType command) ? command : CommandType.Open // Default if parsing fails }; diff --git a/Windows/WebDAVDrive/WebDAVDrive/WebDAVDrive.csproj b/Windows/WebDAVDrive/WebDAVDrive/WebDAVDrive.csproj index 82de317..0a5a1c1 100644 --- a/Windows/WebDAVDrive/WebDAVDrive/WebDAVDrive.csproj +++ b/Windows/WebDAVDrive/WebDAVDrive/WebDAVDrive.csproj @@ -1,6 +1,6 @@ - $(TargetFrameworks);net8.0-windows10.0.19041.0 + $(TargetFrameworks);net9.0-windows10.0.19041.0