Skip to content

Commit

Permalink
v7.0.22091.0-Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed May 16, 2023
1 parent 0a8c58e commit baed9de
Show file tree
Hide file tree
Showing 49 changed files with 516 additions and 884 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="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem" Version="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem" Version="7.0.22091.0-Beta" />
</ItemGroup>
</Project>
8 changes: 7 additions & 1 deletion Common/FileSystemItemMetadataExt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ITHit.FileSystem;
using ITHit.FileSystem.Synchronization;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -11,7 +12,7 @@ namespace ITHit.FileSystem.Samples.Common
/// In addition to properties provided by <see cref="IFileSystemItem"/> this class contains
/// <see cref="ETag"/> and <see cref="Lock"/> properties.
/// </summary>
public class FileSystemItemMetadataExt : IFileSystemItemMetadata
public class FileSystemItemMetadataExt : IFileSystemItemMetadata, IChangedItem
{
/// <inheritdoc/>
public byte[] RemoteStorageItemId { get; set; }
Expand Down Expand Up @@ -51,5 +52,10 @@ public class FileSystemItemMetadataExt : IFileSystemItemMetadata
/// Custom columns data to be displayed in the file manager.
/// </summary>
public IEnumerable<FileSystemItemPropertyData> CustomProperties { get; set; } = new FileSystemItemPropertyData[] { };

/// <summary>
/// Type of change.
/// </summary>
public Change ChangeType { get; set; }
}
}
10 changes: 7 additions & 3 deletions Windows/Common/Core/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ public async Task StopEngineAsync()
/// <summary>
/// Opens Windows File Manager with both remote storage and user file system for testing.
/// </summary>
/// <param name="openRemoteStorage">True if the Remote Storage must be opened. False - otherwise.</param>
/// <remarks>This method is provided solely for the development and testing convenience.</remarks>
public void ShowTestEnvironment()
public void ShowTestEnvironment(bool openRemoteStorage = true)
{
// Enable UTF8 for Console Window and set width.
Console.OutputEncoding = System.Text.Encoding.UTF8;
Expand All @@ -173,8 +174,11 @@ public void ShowTestEnvironment()
// Open Windows File Manager with user file system.
Commands.Open(Engine.Path);

// Open remote storage.
Commands.Open(remoteStorageRootPath);
if (openRemoteStorage)
{
// Open remote storage.
Commands.Open(remoteStorageRootPath);
}
}
#endif
}
Expand Down
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="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="7.0.22091.0-Beta" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22091.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="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="7.0.22091.0-Beta" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\Core\Common.Windows.Core.csproj" />
</ItemGroup>
Expand Down
14 changes: 13 additions & 1 deletion Windows/Common/VirtualDrive/PlaceholderItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;

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


namespace ITHit.FileSystem.Samples.Common.Windows
Expand Down Expand Up @@ -38,13 +39,24 @@ public static async Task<bool> IsModifiedAsync(this PlaceholderItem placeholder,
/// <param name="placeholder">User file system placeholder item.</param>
/// <param name="remoteStorageItem">Remote storage item metadata.</param>
/// <returns>A task object that can be awaited.</returns>
public static async Task SavePropertiesAsync(this PlaceholderItem placeholder, FileSystemItemMetadataExt metadata)
public static async Task SavePropertiesAsync(this PlaceholderItem placeholder, FileSystemItemMetadataExt metadata, ILogger logger = null)
{
// Save lock.
if (metadata.Lock != null)
{
placeholder.SetLockInfo(metadata.Lock);
}
else
{
if (placeholder.TryGetLockInfo(out _) && placeholder.TryDeleteLockInfo())
{
PlaceholderItem.UpdateUI(placeholder.Path);
if (logger != null)
{
logger.LogMessage("Unlocked", placeholder.Path);
}
}
}

// Save eTag.
if (metadata.ETag != null)
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="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="7.0.22091.0-Beta" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
Expand Down
7 changes: 4 additions & 3 deletions Windows/VirtualDrive/VirtualDrive/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ITHit.FileSystem.Windows;
using ITHit.FileSystem.Samples.Common.Windows;
using ITHit.FileSystem.Windows.Package;
using ITHit.FileSystem;

namespace VirtualDrive
{
Expand Down Expand Up @@ -112,7 +113,7 @@ static async Task Main(string[] args)
using (ShellExtension.ShellExtensions.StartComServer(Settings.ShellExtensionsComServerRpcEnabled))
{
// Run the User File System Engine.
await RunEngine();
await RunEngineAsync();
}
}
catch (Exception ex)
Expand All @@ -134,7 +135,7 @@ private static void ValidatePackagePrerequisites()
}
}

private static async Task RunEngine()
private static async Task RunEngineAsync()
{
// Register sync root and create app folders.
await registrar.RegisterSyncRootAsync(Settings.ProductName, Path.Combine(Settings.IconsFolderPath, "Drive.ico"), Settings.ShellExtensionsComServerExePath);
Expand All @@ -158,7 +159,7 @@ private static async Task RunEngine()
// Set the remote storage item ID for the root item. It will be passed to the IEngine.GetFileSystemItemAsync()
// method as a remoteStorageItemId parameter when a root folder is requested.
byte[] itemId = WindowsFileSystemItem.GetItemIdByPath(Settings.RemoteStorageRootPath);
Engine.Placeholders.GetRootItem().SetRemoteStorageItemId(itemId);
Engine.SetRemoteStorageRootItemId(itemId);

// Print console commands.
consoleProcessor.PrintHelp();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This folder demonstrates how to limit folder operations using IFolder.GetFolderOperationControlAsync() method.
When a user copies, moves, deletes, renames, hydrates or dehydrates this folder a message box is displayed to confirm or cancel the operation.
When a user copies, moves, deletes, renames, hydrates or dehydrates this folder, a message box is displayed to confirm or cancel the operation.
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="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows.Package" Version="7.0.22091.0-Beta" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\..\Common\VirtualDrive\Common.Windows.VirtualDrive.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Windows/VirtualDrive/VirtualDrive/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Your virtual file system will be mounted under this path.
// Make sure to delete the all plceholders created by previous version of the software under the sync root.
"UserFileSystemRootPath": "%USERPROFILE%\\VirtualDriveV6\\",
"UserFileSystemRootPath": "%USERPROFILE%\\VirtualDriveV7\\",


// Full synchronization interval in milliseconds.
Expand Down
2 changes: 1 addition & 1 deletion Windows/VirtualFileSystem/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Your virtual file system will be mounted under this path.
// Make sure to delete the all plceholders created by previous version of the software under the sync root.
"UserFileSystemRootPath": "%USERPROFILE%\\VFSv6\\",
"UserFileSystemRootPath": "%USERPROFILE%\\VFSv7\\"


// To test performance:
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="6.4.21218.0" />
<PackageReference Include="ITHit.FileSystem.Windows.ShellExtension" Version="7.0.22091.0-Beta" />
</ItemGroup>
<ItemGroup>
<None Update="log4net.config">
Expand Down
2 changes: 1 addition & 1 deletion Windows/WebDAVDrive/WebDAVDrive.UI/WebDAVDrive.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.13" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.774.44" />
<PackageReference Include="ITHitWebDAVClient" Version="6.0.4076" />
<PackageReference Include="ITHitWebDAVClient" Version="7.0.4627-Beta" />
</ItemGroup>

<ItemGroup>
Expand Down
33 changes: 29 additions & 4 deletions Windows/WebDAVDrive/WebDAVDrive/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ITHit.FileSystem.Windows;
using ITHit.FileSystem.Samples.Common;
using Client = ITHit.WebDAV.Client;
using System.Text;

namespace WebDAVDrive
{
Expand Down Expand Up @@ -106,10 +107,18 @@ public static FileSystemItemMetadataExt GetUserFileSystemItemMetadata(Client.IHi
}

userFileSystemItem.Name = remoteStorageItem.DisplayName;
userFileSystemItem.CreationTime = remoteStorageItem.CreationDate;
userFileSystemItem.LastWriteTime = remoteStorageItem.LastModified;
userFileSystemItem.LastAccessTime = remoteStorageItem.LastModified;
userFileSystemItem.ChangeTime = remoteStorageItem.LastModified;

// In case the item is deleted, the min value is returned.
if (remoteStorageItem.CreationDate != DateTime.MinValue)
{
userFileSystemItem.CreationTime = remoteStorageItem.CreationDate;
userFileSystemItem.LastWriteTime = remoteStorageItem.LastModified;
userFileSystemItem.LastAccessTime = remoteStorageItem.LastModified;
userFileSystemItem.ChangeTime = remoteStorageItem.LastModified;
}

userFileSystemItem.RemoteStorageItemId = GetPropertyValue(remoteStorageItem, "resource-id");
userFileSystemItem.RemoteStorageParentItemId = GetPropertyValue(remoteStorageItem, "parent-resource-id");

// Set information about third-party lock, if any.
Client.LockInfo lockInfo = remoteStorageItem.ActiveLocks.FirstOrDefault();
Expand All @@ -133,5 +142,21 @@ public static FileSystemItemMetadataExt GetUserFileSystemItemMetadata(Client.IHi

return userFileSystemItem;
}

/// <summary>
/// Returns property value. If the property does not exist, returns default value.
/// </summary>
private static byte[] GetPropertyValue(Client.IHierarchyItem remoteStorageItem, string propertyName)
{
byte[] resultValue = null;

Client.Property property = remoteStorageItem.Properties.Where(p => p.Name.Name == propertyName).FirstOrDefault();
if (property != null)
{
resultValue = Encoding.UTF8.GetBytes(property.StringValue);
}

return resultValue;
}
}
}
28 changes: 25 additions & 3 deletions Windows/WebDAVDrive/WebDAVDrive/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

using WebDAVDrive.UI;
using WebDAVDrive.UI.ViewModels;
using ITHit.FileSystem.Windows;
using Windows.Media.Protection.PlayReady;

namespace WebDAVDrive
{
Expand Down Expand Up @@ -138,7 +140,7 @@ static async Task Main(string[] args)
using (ShellExtension.ShellExtensions.StartComServer(Settings.ShellExtensionsComServerRpcEnabled))
{
// Run the User File System Engine.
await RunEngine();
await RunEngineAsync();
}
}
catch (Exception ex)
Expand All @@ -160,7 +162,7 @@ private static void ValidatePackagePrerequisites()
}
}

private static async Task RunEngine()
private static async Task RunEngineAsync()
{
// Register sync root and create app folders.
await registrar.RegisterSyncRootAsync(Settings.ProductName, Path.Combine(Settings.IconsFolderPath, "Drive.ico"), Settings.ShellExtensionsComServerExePath);
Expand Down Expand Up @@ -191,13 +193,33 @@ private static async Task RunEngine()
// Print Engine config, settings, logging headers.
await logFormatter.PrintEngineStartInfoAsync(Engine);

#if DEBUG
// Open remote storage.
Commands.Open(Settings.WebDAVServerUrl);
#endif
using (DavClient = CreateWebDavSession(Engine.InstanceId))
{
// Set the remote storage item ID for the root item. It will be passed to the IEngine.GetFileSystemItemAsync()
// method as a remoteStorageItemId parameter when a root folder is requested.
PropertyName[] propNames = new PropertyName[2];
propNames[0] = new PropertyName("resource-id", "DAV:");
propNames[1] = new PropertyName("parent-resource-id", "DAV:");
byte[] remoteStorageItemId = Mapping.GetUserFileSystemItemMetadata((await DavClient.GetItemAsync(new Uri(Settings.WebDAVServerUrl), propNames)).WebDavResponse).RemoteStorageItemId;

if (remoteStorageItemId != null)
{
Engine.SetRemoteStorageRootItemId(remoteStorageItemId);
}
else
{
log.Error("remote-id or parent-resource-id is not found. Your WebDAV server does not support collection synchronization. Upgrade your .NET WebDAV server to v13.2 or Java WebDAV server to v6.2 or later version.");
}

// Start processing OS file system calls.
await Engine.StartAsync();
#if DEBUG
// Opens Windows File Manager with user file system folder and remote storage folder.
commands.ShowTestEnvironment();
commands.ShowTestEnvironment(false);
#endif
// Keep this application running and reading user input
// untill the tray app exits or an exit key in the console is selected.
Expand Down
Loading

0 comments on commit baed9de

Please sign in to comment.