Skip to content

Commit

Permalink
v7.0.22106.0-Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed May 18, 2023
1 parent baed9de commit 1986f61
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 250 deletions.
4 changes: 2 additions & 2 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22106.0-Beta" />
<PackageReference Include="ITHit.FileSystem" Version="7.0.22106.0-Beta" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Windows/Common/Core/Common.Windows.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="7.0.22106.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22106.0-Beta" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Compile Remove="IVirtualFolder.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22106.0-Beta" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\Core\Common.Windows.Core.csproj" />
</ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions Windows/Common/VirtualDrive/PlaceholderItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System.Threading.Tasks;

using ITHit.FileSystem.Windows;
using ITHit.FileSystem.Windows.Properties;


namespace ITHit.FileSystem.Samples.Common.Windows
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="7.0.22106.0-Beta" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
Expand Down
2 changes: 1 addition & 1 deletion Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This is an advanced project with ETags support, Microsoft Office documents editi
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="7.0.22106.0-Beta" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\..\Common\VirtualDrive\Common.Windows.VirtualDrive.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Copyright>IT HIT LTD.</Copyright>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="7.0.22106.0-Beta" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
Expand Down
5 changes: 0 additions & 5 deletions Windows/WebDAVDrive/WebDAVDrive/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public class AppSettings : Settings
/// </summary>
public double SyncIntervalMs { get; set; }

/// <summary>
/// Full incoming synchronization interval in milliseconds.
/// </summary>
public double IncomingFullSyncIntervalMs { get; set; }

/// <summary>
/// Throttling max of create/update/read concurrent requests.
/// </summary>
Expand Down
194 changes: 0 additions & 194 deletions Windows/WebDAVDrive/WebDAVDrive/IncomingFullSync.cs

This file was deleted.

1 change: 0 additions & 1 deletion Windows/WebDAVDrive/WebDAVDrive/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ private static async Task RunEngineAsync()
commands.RemoteStorageMonitor = Engine.RemoteStorageMonitor;

Engine.SyncService.SyncIntervalMs = Settings.SyncIntervalMs;
Engine.IncomingFullSync.SyncIntervalMs = Settings.IncomingFullSyncIntervalMs;
Engine.AutoLock = Settings.AutoLock;
Engine.MaxTransferConcurrentRequests = Settings.MaxTransferConcurrentRequests.Value;
Engine.MaxOperationsConcurrentRequests = Settings.MaxOperationsConcurrentRequests.Value;
Expand Down
43 changes: 25 additions & 18 deletions Windows/WebDAVDrive/WebDAVDrive/RemoteStorageMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,27 @@ private async Task StartMonitoringAsync(NetworkCredential credentials, CookieCol

Logger.LogMessage("Started", webSocketServerUrl);

// sync items before getting websocket messages.
await ProcessAsync(new WebSocketMessage
{
EventType = "start monitoring."
}, true);

var rcvBuffer = new ArraySegment<byte>(new byte[2048]);
while (true)
{
WebSocketReceiveResult rcvResult = await clientWebSocket.ReceiveAsync(rcvBuffer, cancellationTokenSource.Token);
byte[] msgBytes = rcvBuffer.Skip(rcvBuffer.Offset).Take(rcvResult.Count).ToArray();
string rcvMsg = Encoding.UTF8.GetString(msgBytes);
await ProcessAsync(rcvMsg);
await ProcessAsync(JsonSerializer.Deserialize<WebSocketMessage>(rcvMsg, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
}));
}
}

/// <summary>
/// Starts websockets to monitor changes in remote storage.
/// Starts WebSockets to monitor changes in the remote storage.
/// </summary>
public async Task StartAsync(CancellationToken cancellationToken = default)
{
Expand All @@ -114,13 +123,13 @@ await Task.Factory.StartNew(
}
catch (Exception e) when (e is WebSocketException || e is AggregateException)
{
// Start socket after first success WebDAV PROPFIND. Restart socket when it disconnects.
// Start socket after first successeful WebDAV PROPFIND. Restart socket if disconnected.
if (clientWebSocket != null && clientWebSocket?.State != WebSocketState.Closed)
{
Logger.LogError(e.Message, webSocketServerUrl);
}

// Delay websocket connect to not overload it on network disappear.
// Delay WebSocket connection to avoid overload on network disconnections.
await Task.Delay(TimeSpan.FromSeconds(2));
repeat = true;
};
Expand Down Expand Up @@ -153,33 +162,31 @@ public async Task StopAsync()
/// <summary>
/// Processes notification received from server via WebSockets. Triggers reading all changes from the server.
/// </summary>
internal async Task ProcessAsync(string jsonString)
/// <param name="webSocketMessage">Web Socket message.</param>
/// <param name="forceSync">force sync items.</param>
internal async Task ProcessAsync(WebSocketMessage webSocketMessage, bool forceSync = false)
{
WebSocketMessage jsonMessage = JsonSerializer.Deserialize<WebSocketMessage>(jsonString, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
string remoteStoragePath = Mapping.GetAbsoluteUri(jsonMessage.ItemPath);
string remoteStoragePath = Mapping.GetAbsoluteUri(webSocketMessage.ItemPath);

// Check if remote URL starts with WebDAVServerUrl.
if (remoteStoragePath.StartsWith(Program.Settings.WebDAVServerUrl, StringComparison.InvariantCultureIgnoreCase))
if (remoteStoragePath.StartsWith(Program.Settings.WebDAVServerUrl, StringComparison.InvariantCultureIgnoreCase) || forceSync)
{
Logger.LogDebug($"EventType: {jsonMessage.EventType}", jsonMessage.ItemPath, jsonMessage.TargetPath);
Logger.LogDebug($"EventType: {webSocketMessage.EventType}", webSocketMessage.ItemPath, webSocketMessage.TargetPath);
try
{
// triggers ISynchronizationCollection.GetChangesAsync call to get all changes from server.
await (Engine.ServerNotifications(Engine.Path, Logger) as IServerCollectionNotifications)
.ProcessChangesAsync(async (metadata, userFileSystemPath) =>
// Triggers ISynchronizationCollection.GetChangesAsync() call to get all changes from the remote storage.
await Engine.ServerNotifications(Engine.Path, Logger)
.ProcessChangesAsync(async (metadata, userFileSystemPath) =>
await Engine.Placeholders.GetItem(userFileSystemPath).SavePropertiesAsync(metadata as FileSystemItemMetadataExt, Logger));

}
catch(Exception ex)
catch (Exception ex)
{
Logger.LogError(nameof(ProcessAsync), Engine.Path, null, ex);
Logger.LogError("Failed to process changes", Engine.Path, null, ex);
}
}
}

private bool disposedValue = false; // To detect redundant calls

protected virtual void Dispose(bool disposing)
Expand Down
Loading

0 comments on commit 1986f61

Please sign in to comment.