Skip to content

Commit

Permalink
v4.3.12907.0-Beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed Apr 1, 2022
1 parent 4b7e4af commit 35fa937
Show file tree
Hide file tree
Showing 34 changed files with 82 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<RootNamespace>ITHit.FileSystem.Samples.Common</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem" Version="4.2.12691.0-Beta2" />
<PackageReference Include="ITHit.FileSystem" Version="4.3.12907.0-Beta2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Windows/Common/Core/Common.Windows.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.2.12691.0-Beta2" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
</ItemGroup>
</Project>
11 changes: 7 additions & 4 deletions Windows/Common/Rpc/GrpcClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using ITHit.FileSystem.Samples.Common.Windows.Rpc.Generated;
using GrpcDotNetNamedPipes;
using System.IO;
using System.Security.Principal;

namespace ITHit.FileSystem.Samples.Common.Windows.Rpc
{
Expand All @@ -13,8 +15,7 @@ public class GrpcClient

public GrpcClient(string channelName)
{
if (string.IsNullOrEmpty(rpcCommunicationChannelName))
rpcCommunicationChannelName = channelName;
rpcCommunicationChannelName = channelName;
}

public const int ConnectionTimeoutMs = 1000;
Expand All @@ -35,10 +36,12 @@ private static ShellExtensionRpc.ShellExtensionRpcClient Connect()
{
ConnectionTimeout = ConnectionTimeoutMs,
CurrentUserOnly = true,
ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.None
ImpersonationLevel = TokenImpersonationLevel.None
};

NamedPipeChannel channel = new NamedPipeChannel(".", rpcCommunicationChannelName, options);
var pipeName = Path.Combine(WindowsIdentity.GetCurrent().Owner.Value, rpcCommunicationChannelName);

NamedPipeChannel channel = new NamedPipeChannel(".", pipeName, options);
ShellExtensionRpc.ShellExtensionRpcClient client = new ShellExtensionRpc.ShellExtensionRpcClient(channel);
return client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.2.12691.0-Beta2" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\Rpc.Proto\Common.Windows.Rpc.Proto.csproj" />
<ProjectReference Include="..\Rpc\Common.Windows.Rpc.csproj" />
Expand Down
6 changes: 5 additions & 1 deletion Windows/Common/ShellExtension/ContextMenusProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
namespace ITHit.FileSystem.Samples.Common.Windows.ShellExtension
{
/// <summary>
/// Base class which implements logic to extend Windows Explorer commands.
/// Common code to extend Windows Explorer commands.
/// </summary>
/// <remarks>
/// You will derive your class from this class to implement your Windows Explorer context menu.
/// Typically you do not need to make any changes in this class.
/// </remarks>
public abstract class ContextMenusProviderBase : IExplorerCommand
{
/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions Windows/Common/ShellExtension/ThumbnailProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

namespace ITHit.FileSystem.Samples.Common.Windows.ShellExtension.Thumbnails
{

/// <summary>
/// Common code for a thumbnails provider.
/// </summary>
/// <remarks>
/// You will derive your class from this class to implement your Thumbnails provider Windows Shell Extension
/// Typically you do not need to make any changes in this class.
/// </remarks>
public abstract class ThumbnailProviderBase : InitializedWithItem, IThumbnailProvider
{
public abstract Task<byte[]> GetThumbnailsAsync(string filePath, uint size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.2.12691.0-Beta2" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.3.12907.0-Beta2" />
<ProjectReference Include="..\..\..\Common\Common.csproj" />
<ProjectReference Include="..\Core\Common.Windows.Core.csproj" />
<ProjectReference Include="..\Rpc.Proto\Common.Windows.Rpc.Proto.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Windows/Common/VirtualDrive/Filter/FilterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static bool AvoidSync(string path)
}

/// <summary>
/// Returns true if file system contains an application lock-file (~$*.docx, *.dwl, *.dwl2) in file
/// Returns true if file system contains an application lock-file (~$*.docx, *.dwl, *.dwl2, etc) in the file
/// system that corresponds to the provided path to the file file. False - otherwise.
/// </summary>
/// <param name="path">Path to the file to check the lock-file for.</param>
Expand Down
10 changes: 6 additions & 4 deletions Windows/Common/VirtualDrive/Rpc/GrpcServer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using ITHit.FileSystem.Windows;
using ITHit.FileSystem.Samples.Common.Windows.Rpc.Generated;
using GrpcDotNetNamedPipes;
using log4net;
using System.IO.Pipes;
using System.Security.Principal;
using System.Security.AccessControl;
using System.IO;

namespace ITHit.FileSystem.Samples.Common.Windows.Rpc
{
Expand Down Expand Up @@ -40,14 +40,16 @@ public void Start()
Stop();
}

NamedPipeServer server = new NamedPipeServer(rpcCommunicationChannelName, new NamedPipeServerOptions() {
var pipeName = Path.Combine(WindowsIdentity.GetCurrent().Owner.Value, rpcCommunicationChannelName);

NamedPipeServer server = new NamedPipeServer(pipeName, new NamedPipeServerOptions() {
CurrentUserOnly = true
});
ShellExtensionRpc.BindService(server.ServiceBinder, new GprcServerServiceImpl(engine, this));
ShellExtensionRpc.BindService(server.ServiceBinder, new GrpcServerServiceImpl(engine, this));
server.Start();
namedPipeServer = server;

LogMessage("Started", rpcCommunicationChannelName);
LogMessage("Started", pipeName);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ namespace ITHit.FileSystem.Samples.Common.Windows.Rpc
/// <summary>
/// RPC methods handler.
/// </summary>
public class GprcServerServiceImpl : ShellExtensionRpc.ShellExtensionRpcBase
public class GrpcServerServiceImpl : ShellExtensionRpc.ShellExtensionRpcBase
{
private static EmptyMessage EmptyMessage = new EmptyMessage();

private VirtualEngineBase engine;
private ILogger logger;

public GprcServerServiceImpl(VirtualEngineBase engine, ILogger logger)
public GrpcServerServiceImpl(VirtualEngineBase engine, ILogger logger)
{
this.engine = engine;
this.logger = logger;
Expand Down
2 changes: 1 addition & 1 deletion Windows/Common/VirtualDrive/VirtualEngineBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class VirtualEngineBase : EngineWindows
private readonly string iconsFolderPath;

/// <summary>
/// Gprc server control to communicate with Windows Explorer
/// Grpc server control to communicate with Windows Explorer
/// context menu and other components on this machine.
/// </summary>
private readonly GrpcServer grpcServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<Identity
Name="38f8ee88-19d0-48a3-ad8e-904a6cf3ca17"
Publisher="CN=IT Hit LTD., O=IT Hit LTD., STREET=86 Kimbark blvd, L=Toronto, S=Ontario, PostalCode=M5N2Y1, C=CA"
Publisher="CN=VirtualDrivePackagePublisher"
Version="1.0.0.0" />

<Properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace VirtualDrive.ShellExtension
{
/// <summary>
/// Implements Windows Explorer context menu logic.
/// Implements Windows Explorer context menu.
/// </summary>
[ComVisible(true)]
[ProgId("VirtualDrive.ContextMenusProvider"), Guid(ContextMenusClass)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

namespace VirtualDrive.ShellExtension
{
// It is Windows Shell Extension code
/// <summary>
/// Thumbnails provider Windows Shell Extension.
/// </summary>
[ComVisible(true)]
[ProgId("VirtualDrive.ThumbnailProvider"), Guid(ThumbnailClass)]
public class ThumbnailProvider : ThumbnailProviderBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</ClCompile>
<ResourceCompile Include="Common_Windows_WinRT_ShellExtension.rc" />
<Manifest Include="Common_Windows_WinRT_ShellExtension.exe.manifest" />
<None Include="..\..\Common\WinRT.ShellExtension\packages.config" />
<None Include="packages.config" />
<None Include="PropertySheet.props" />
<Text Include="readme.txt">
<DeploymentContent>false</DeploymentContent>
Expand Down
6 changes: 3 additions & 3 deletions Windows/VirtualDrive/VirtualDrive/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static string GetRemoteStoragePathById(byte[] remoteStorageId)
/// Gets a user file system item info from the remote storage data.
/// </summary>
/// <param name="remoteStorageItem">Remote storage item info.</param>
/// <returns>User file system item info.</returns>
/// <returns>File or folder metadata that corresponds to the <paramref name="remoteStorageItem"/> parameter.</returns>
public static FileSystemItemMetadataExt GetUserFileSysteItemMetadata(FileSystemInfo remoteStorageItem)
{
FileSystemItemMetadataExt userFileSystemItem;
Expand All @@ -91,8 +91,8 @@ public static FileSystemItemMetadataExt GetUserFileSysteItemMetadata(FileSystemI
userFileSystemItem = new FolderMetadataExt();
}

// Store you remote storage item ID in this property.
// It will be passed to IEngine.GetFileSystemItemAsync() during every operation.
// Store your remote storage item ID in this property.
// It will be passed to the IEngine.GetFileSystemItemAsync() method during every operation.
userFileSystemItem.RemoteStorageItemId = WindowsFileSystemItem.GetItemIdByPath(remoteStorageItem.FullName);

userFileSystemItem.Name = remoteStorageItem.Name;
Expand Down
4 changes: 0 additions & 4 deletions Windows/VirtualDrive/VirtualDrive/RemoteStorageMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ private async void RenamedAsync(object sender, RenamedEventArgs e)
// Because of the on-demand population the file or folder placeholder may not exist in the user file system.
if (await engine.ServerNotifications(userFileSystemOldPath).MoveToAsync(userFileSystemNewPath))
{
// As soon as in this sample we use USN as a ETag, and USN chandes on move,
// we need to update it for hydrated files.
//await engine.Mapping.UpdateETagAsync(remoteStorageNewPath, userFileSystemNewPath);

LogMessage("Renamed succesefully", userFileSystemOldPath, userFileSystemNewPath);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Windows/VirtualDrive/VirtualDrive/VirtualFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task ValidateDataAsync(long offset, long length, IValidateDataOpera
}

/// <inheritdoc/>
public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null, IOperationContext operationContext = null)
public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null, IOperationContext operationContext = null, IInSyncResultContext inSyncResultContext = null)
{
Logger.LogMessage($"{nameof(IFile)}.{nameof(WriteAsync)}()", UserFileSystemPath, default, operationContext);

Expand Down
4 changes: 2 additions & 2 deletions Windows/VirtualDrive/VirtualDrive/VirtualFileSystemItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task MoveToAsync(string targetUserFileSystemPath, byte[] targetPare
}

/// <inheritdoc/>
public async Task MoveToCompletionAsync(string targetUserFileSystemPath, byte[] targetFolderRemoteStorageItemId, IMoveCompletionContext operationContext = null, IResultContext resultContext = null)
public async Task MoveToCompletionAsync(string targetUserFileSystemPath, byte[] targetFolderRemoteStorageItemId, IMoveCompletionContext operationContext = null, IInSyncStatusResultContext resultContext = null)
{
string userFileSystemNewPath = targetUserFileSystemPath;
string userFileSystemOldPath = this.UserFileSystemPath;
Expand Down Expand Up @@ -106,7 +106,7 @@ public async Task DeleteAsync(IOperationContext operationContext, IConfirmationR
}

/// <inheritdoc/>
public async Task DeleteCompletionAsync(IOperationContext operationContext, IResultContext resultContext)
public async Task DeleteCompletionAsync(IOperationContext operationContext, IInSyncStatusResultContext resultContext)
{
// On Windows, for move with overwrite on folders to function correctly,
// the deletion of the folder in the remote storage must be done in DeleteCompletionAsync()
Expand Down
8 changes: 4 additions & 4 deletions Windows/VirtualDrive/VirtualDrive/VirtualFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public VirtualFolder(string path, byte[] remoteStorageItemId, VirtualEngine engi
}

/// <inheritdoc/>
public async Task<byte[]> CreateFileAsync(IFileMetadata fileMetadata, Stream content = null)
public async Task<byte[]> CreateFileAsync(IFileMetadata fileMetadata, Stream content = null, IInSyncResultContext inSyncResultContext = null)
{
string userFileSystemNewItemPath = Path.Combine(UserFileSystemPath, fileMetadata.Name);
Logger.LogMessage($"{nameof(IFolder)}.{nameof(CreateFileAsync)}()", userFileSystemNewItemPath);
Expand Down Expand Up @@ -67,10 +67,10 @@ public async Task<byte[]> CreateFileAsync(IFileMetadata fileMetadata, Stream con
}

/// <inheritdoc/>
public async Task<byte[]> CreateFolderAsync(IFolderMetadata folderMetadata)
public async Task<byte[]> CreateFolderAsync(IFolderMetadata folderMetadata, IInSyncResultContext inSyncResultContext = null)
{
string userFileSystemNewItemPath = Path.Combine(UserFileSystemPath, folderMetadata.Name);
Logger.LogMessage($"{nameof(IFolder)}.{nameof(CreateFolderAsync)}() Start", userFileSystemNewItemPath);
Logger.LogMessage($"{nameof(IFolder)}.{nameof(CreateFolderAsync)}()", userFileSystemNewItemPath);

string remoteStoragePath = Mapping.GetRemoteStoragePathById(RemoteStorageItemId);
DirectoryInfo remoteStorageItem = new DirectoryInfo(Path.Combine(remoteStoragePath, folderMetadata.Name));
Expand Down Expand Up @@ -146,7 +146,7 @@ public async Task<IEnumerable<FileSystemItemMetadataExt>> EnumerateChildrenAsync
}

/// <inheritdoc/>
public async Task WriteAsync(IFolderMetadata folderMetadata, IOperationContext operationContext = null)
public async Task WriteAsync(IFolderMetadata folderMetadata, IOperationContext operationContext = null, IInSyncResultContext inSyncResultContext = null)
{
Logger.LogMessage($"{nameof(IFolder)}.{nameof(WriteAsync)}()", UserFileSystemPath, default, operationContext);

Expand Down
6 changes: 3 additions & 3 deletions Windows/VirtualFileSystem/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static string GetRemoteStoragePathById(byte[] remoteStorageId)
/// In your real-life file system you will change the input parameter type of this method and rewrite it
/// to map your remote storage item data to the user file system data.
/// </remarks>
/// <returns>File or folder metadata that corresponds to the <paramref name="remoteStorageItem"/>.</returns>
/// <returns>File or folder metadata that corresponds to the <paramref name="remoteStorageItem"/> parameter.</returns>
public static IFileSystemItemMetadata GetUserFileSysteItemMetadata(FileSystemInfo remoteStorageItem)
{
IFileSystemItemMetadata userFileSystemItem;
Expand All @@ -70,8 +70,8 @@ public static IFileSystemItemMetadata GetUserFileSysteItemMetadata(FileSystemInf
userFileSystemItem = new FolderMetadata();
}

// Store you remote storage item ID in this property.
// It will be passed to IEngine.GetFileSystemItemAsync() during every operation.
// Store your remote storage item ID in this property.
// It will be passed to the IEngine.GetFileSystemItemAsync() method during every operation.
userFileSystemItem.RemoteStorageItemId = WindowsFileSystemItem.GetItemIdByPath(remoteStorageItem.FullName);

userFileSystemItem.Name = remoteStorageItem.Name;
Expand Down
2 changes: 1 addition & 1 deletion Windows/VirtualFileSystem/RemoteStorageMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private async void RenamedAsync(object sender, RenamedEventArgs e)
{
// Because of the on-demand population the file or folder placeholder may not exist in the user file system.
// In this case the IServerNotifications.MoveToAsync() call is ignored.
LogMessage("Renamed succesefully:", userFileSystemOldPath, userFileSystemNewPath);
LogMessage("Renamed succesefully", userFileSystemOldPath, userFileSystemNewPath);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Windows/VirtualFileSystem/VirtualFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public async Task ValidateDataAsync(long offset, long length, IValidateDataOpera
}

/// <inheritdoc/>
public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null, IOperationContext operationContext = null)
public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null, IOperationContext operationContext = null, IInSyncResultContext inSyncResultContext = null)
{
Logger.LogMessage($"{nameof(IFile)}.{nameof(WriteAsync)}()", UserFileSystemPath, default, operationContext);

Expand All @@ -101,7 +101,6 @@ public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null,
remoteStorageItem.LastWriteTimeUtc = fileMetadata.LastWriteTime.UtcDateTime;
remoteStorageItem.LastAccessTimeUtc = fileMetadata.LastAccessTime.UtcDateTime;
remoteStorageItem.LastWriteTimeUtc = fileMetadata.LastWriteTime.UtcDateTime;

}
}
}
4 changes: 2 additions & 2 deletions Windows/VirtualFileSystem/VirtualFileSystemItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task MoveToAsync(string targetUserFileSystemPath, byte[] targetFold
}

/// <inheritdoc/>
public async Task MoveToCompletionAsync(string targetUserFileSystemPath, byte[] targetFolderRemoteStorageItemId, IMoveCompletionContext operationContext = null, IResultContext resultContext = null)
public async Task MoveToCompletionAsync(string targetUserFileSystemPath, byte[] targetFolderRemoteStorageItemId, IMoveCompletionContext operationContext = null, IInSyncStatusResultContext resultContext = null)
{
string userFileSystemNewPath = targetUserFileSystemPath;
string userFileSystemOldPath = this.UserFileSystemPath;
Expand Down Expand Up @@ -97,7 +97,7 @@ public async Task DeleteAsync(IOperationContext operationContext = null, IConfir
}

/// <inheritdoc/>
public async Task DeleteCompletionAsync(IOperationContext operationContext = null, IResultContext resultContext = null)
public async Task DeleteCompletionAsync(IOperationContext operationContext = null, IInSyncStatusResultContext resultContext = null)
{
// On Windows, for rename with overwrite to function properly for folders,
// the deletion of the folder in the remote storage must be done in DeleteCompletionAsync()
Expand Down
Loading

0 comments on commit 35fa937

Please sign in to comment.