Skip to content

Commit

Permalink
v3.2.8936.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ITHitBuild committed Jul 16, 2021
1 parent 9e4a543 commit cbd5a1c
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<Description>Contains functionality common for all Virtual Drive samples, both for Windows and macOS.</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem" Version="3.2.8901.0" />
<PackageReference Include="ITHit.FileSystem" Version="3.2.8936.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Windows/Common/Common.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="3.2.8901.0" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="3.2.8936.0" />
<ProjectReference Include="..\..\Common\Common.csproj" />
</ItemGroup>
</Project>
16 changes: 8 additions & 8 deletions Windows/UserFileSystemSamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ Global
{51F6CFCC-AB57-40DD-AADA-6299A2C6B941}.Release|x64.Build.0 = Release|Any CPU
{51F6CFCC-AB57-40DD-AADA-6299A2C6B941}.Release|x86.ActiveCfg = Release|Any CPU
{51F6CFCC-AB57-40DD-AADA-6299A2C6B941}.Release|x86.Build.0 = Release|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|Any CPU.ActiveCfg = Debug|x64
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|Any CPU.Build.0 = Debug|x64
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|ARM.ActiveCfg = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|ARM.Build.0 = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|ARM64.Build.0 = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|x64.ActiveCfg = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|x64.Build.0 = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|x64.ActiveCfg = Debug|x64
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|x64.Build.0 = Debug|x64
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|x86.ActiveCfg = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Debug|x86.Build.0 = Debug|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -137,14 +137,14 @@ Global
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Release|x64.Build.0 = Release|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Release|x86.ActiveCfg = Release|Any CPU
{648FB01F-0C4A-409E-A48A-E6722F626AB8}.Release|x86.Build.0 = Release|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|Any CPU.ActiveCfg = Debug|x64
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|Any CPU.Build.0 = Debug|x64
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|ARM.Build.0 = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|ARM64.Build.0 = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|x64.ActiveCfg = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|x64.Build.0 = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|x64.ActiveCfg = Debug|x64
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|x64.Build.0 = Debug|x64
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|x86.ActiveCfg = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Debug|x86.Build.0 = Debug|Any CPU
{1E765516-497B-4546-8C38-DB452915ACBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,36 @@
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\VirtualDrive\VirtualDrive.csproj</EntryPointProjectUniqueName>
<GenerateAppInstallerFile>True</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<AppInstallerUri></AppInstallerUri>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableComHosting>True</EnableComHosting>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
68 changes: 37 additions & 31 deletions Windows/VirtualDrive/VirtualDrive/MsOfficeDocsMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ internal MsOfficeDocsMonitor(string userFileSystemRootPath, VirtualEngine engine
watcher.IncludeSubdirectories = true;
watcher.Path = userFileSystemRootPath;
//watcher.Filter = "*.*";
watcher.NotifyFilter = NotifyFilters.FileName;

// Some applications, such as Notpad++, remove the Offline attribute,
// Attributes filter is required to monitor the Changed event and convert the file back to the plceholder.
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Attributes;
watcher.Error += Error;
watcher.Created += CreatedAsync;
watcher.Changed += ChangedAsync;
Expand Down Expand Up @@ -87,6 +90,38 @@ private async void CreatedAsync(object sender, FileSystemEventArgs e)
private async void ChangedAsync(object sender, FileSystemEventArgs e)
{
LogMessage($"{e.ChangeType}", e.FullPath);

string userFileSystemPath = e.FullPath;
try
{
if (System.IO.File.Exists(userFileSystemPath)
&& !MsOfficeHelper.AvoidMsOfficeSync(userFileSystemPath))
{
if (!PlaceholderItem.IsPlaceholder(userFileSystemPath))
{
if (engine.CustomDataManager(userFileSystemPath).IsNew)
{
await engine.ClientNotifications(userFileSystemPath, this).CreateAsync();
}
else
{
LogMessage("Converting to placeholder", userFileSystemPath);
PlaceholderItem.ConvertToPlaceholder(userFileSystemPath, null, null, false);
await engine.ClientNotifications(userFileSystemPath, this).UpdateAsync();
await engine.CustomDataManager(userFileSystemPath).RefreshCustomColumnsAsync();
}
}
}
}
catch (Exception ex)
{
string userFileSystemOldPath = null;
if (e is RenamedEventArgs)
{
userFileSystemOldPath = (e as RenamedEventArgs).OldFullPath;
}
LogError($"{e.ChangeType} failed", userFileSystemOldPath, userFileSystemPath, ex);
}
}

/// <summary>
Expand All @@ -106,36 +141,7 @@ private async void RenamedAsync(object sender, RenamedEventArgs e)
// for example temp MS Office file was renamed SGE4274H -> file.xlsx,
// we need to convert the file to a pleaceholder and upload it to the remote storage.

LogMessage("Renamed", e.OldFullPath, e.FullPath);

string userFileSystemOldPath = e.OldFullPath;
string userFileSystemNewPath = e.FullPath;
try
{
if (System.IO.File.Exists(userFileSystemNewPath)
&& !MsOfficeHelper.AvoidMsOfficeSync(userFileSystemNewPath))
{
if (!PlaceholderItem.IsPlaceholder(userFileSystemNewPath))
{
if (engine.CustomDataManager(userFileSystemNewPath).IsNew)
{
await engine.ClientNotifications(userFileSystemNewPath, this).CreateAsync();
}
else
{
LogMessage("Converting to placeholder", userFileSystemNewPath);
PlaceholderItem.ConvertToPlaceholder(userFileSystemNewPath, null, null, false);
await engine.ClientNotifications(userFileSystemNewPath, this).UpdateAsync();
await engine.CustomDataManager(userFileSystemNewPath).RefreshCustomColumnsAsync();
}
}
}
}
catch (Exception ex)
{
LogError($"{e.ChangeType} failed", userFileSystemOldPath, userFileSystemNewPath, ex);
}

ChangedAsync(sender, e);
}

private void Error(object sender, ErrorEventArgs e)
Expand Down
35 changes: 23 additions & 12 deletions Windows/VirtualDrive/VirtualDrive/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using log4net;
using log4net.Appender;
using log4net.Config;
using Microsoft.Extensions.Configuration;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Windows.Storage;
using Microsoft.Extensions.Configuration;
using log4net;
using log4net.Config;

using ITHit.FileSystem.Samples.Common.Windows;

Expand Down Expand Up @@ -43,7 +46,10 @@ static async Task Main(string[] args)
// Enable UTF8 for Console Window
Console.OutputEncoding = System.Text.Encoding.UTF8;

log.Info($"\n{System.Diagnostics.Process.GetCurrentProcess().ProcessName} {Settings.AppID}");
log.Info($"\n{Process.GetCurrentProcess().ProcessName} {Settings.AppID}");
log.Info($"\nOS version: {RuntimeInformation.OSDescription}.");
log.Info($"\nEnv version: {RuntimeInformation.FrameworkDescription} {IntPtr.Size * 8}bit.");
log.Info($"\nLog path: {(logRepository.GetAppenders().Where(p => p.GetType() == typeof(RollingFileAppender)).FirstOrDefault() as RollingFileAppender)?.File}.");
log.Info("\nPress 'Q' to unregister file system, delete all files/folders and exit (simulate uninstall with full cleanup).");
log.Info("\nPress 'q' to unregister file system and exit (simulate uninstall).");
log.Info("\nPress any other key to exit without unregistering (simulate reboot).");
Expand All @@ -69,15 +75,15 @@ await Registrar.RegisterAsync(SyncRootId, Settings.UserFileSystemRootPath, Setti
StorageFolder userFileSystemRootFolder = await StorageFolder.GetFolderFromPathAsync(Settings.UserFileSystemRootPath);
log.Info($"\nIndexed state: {(await userFileSystemRootFolder.GetIndexedStateAsync())}\n");

ConsoleKeyInfo exitKey;
ConsoleKeyInfo? exitKey = null;

try
{
Engine = new VirtualEngine(
Settings.UserFileSystemLicense,
Settings.UserFileSystemRootPath,
Settings.ServerDataFolderPath,
Settings.IconsFolderPath,
Settings.UserFileSystemLicense,
Settings.UserFileSystemRootPath,
Settings.ServerDataFolderPath,
Settings.IconsFolderPath,
log);
Engine.AutoLock = Settings.AutoLock;

Expand All @@ -91,25 +97,30 @@ await Registrar.RegisterAsync(SyncRootId, Settings.UserFileSystemRootPath, Setti
// Keep this application running until user input.
exitKey = Console.ReadKey();
}
catch (Exception ex)
{
log.Error(ex);
Console.ReadKey();
}
finally
{
Engine.Dispose();
}

if (exitKey.KeyChar == 'q')
if (exitKey?.KeyChar == 'q')
{
// Unregister during programm uninstall.
await Registrar.UnregisterAsync(SyncRootId);
log.Info($"\n\nUnregistering {Settings.UserFileSystemRootPath} sync root.");
log.Info("\nAll empty file and folder placeholders are deleted. Hydrated placeholders are converted to regular files / folders.\n");
}
else if (exitKey.KeyChar == 'Q')
else if (exitKey?.KeyChar == 'Q')
{
log.Info($"\n\nUnregistering {Settings.UserFileSystemRootPath} sync root.");
log.Info("\nAll files and folders placeholders are deleted.\n");

// Unregister during programm uninstall and delete all files/folder.
await Registrar.UnregisterAsync(SyncRootId);
await Registrar.UnregisterAsync(SyncRootId);

try
{
Expand Down
15 changes: 2 additions & 13 deletions Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
<Company>IT Hit LTD.</Company>
<Product>Virtual Drive</Product>
<Copyright>IT Hit LTD.</Copyright>
<Platforms>AnyCPU</Platforms>
<Platforms>x64</Platforms>
<Description>A virtual drive project in .NET/C# with synchronization support, on-demand loading, selective offline files support, upload and download progress. It synchronizes files and folders both from remote storage to the user file system and from the user file system to remote storage.

To simulate the remote storage, this sample is using a folder in the local file system on the same machine. You can use this project as a strting point for creating a Virtual Drive with advanced features.

This is an advanced project with ETags support, Microsoft Office documents editing, automatic Microsoft Office documents locking, and custom columns in Windows File Manager.</Description>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Framework\**" />
<Compile Remove="RemoteStorageTemplate\**" />
Expand All @@ -32,9 +29,8 @@ This is an advanced project with ETags support, Microsoft Office documents editi
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ITHit.FileSystem.Windows" Version="3.2.8901.0" />
<PackageReference Include="ITHit.FileSystem.Windows" Version="3.2.8936.0" />
<ProjectReference Include="..\..\Common\Common.Windows.csproj" />
<ProjectReference Include="..\VirtualDrive.ThumbnailProvider\VirtualDrive.ThumbnailProvider.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
Expand Down Expand Up @@ -68,11 +64,4 @@ This is an advanced project with ETags support, Microsoft Office documents editi
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!--Copy *.json deps files from VirtualDrive.ThumbnailProvider-->
<Target Name="CopyDepsFiles" AfterTargets="AfterBuild">
<ItemGroup>
<DepsFilePaths Include="..\VirtualDrive.ThumbnailProvider\bin\$(Configuration)\$(TargetFramework)\*.json" />
</ItemGroup>
<Copy SourceFiles="@(DepsFilePaths)" DestinationFolder="$(OutDir)" />
</Target>
</Project>
6 changes: 0 additions & 6 deletions Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj.user

This file was deleted.

Loading

0 comments on commit cbd5a1c

Please sign in to comment.