Skip to content

Commit f5a877d

Browse files
committed
v4.0.10295.0-Beta
1 parent 41bdc0c commit f5a877d

31 files changed

+334
-210
lines changed

Common/Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<Description>Contains functionality common for all Virtual Drive samples, both for Windows and macOS.</Description>
99
</PropertyGroup>
1010
<ItemGroup>
11-
<PackageReference Include="ITHit.FileSystem" Version="3.3.9602.0" />
11+
<PackageReference Include="ITHit.FileSystem" Version="4.0.10295.0-Beta" />
1212
</ItemGroup>
1313
</Project>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
4+
<CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata>
45
<Description>Contains functionality common for all Windows Virtual Drive samples.</Description>
56
<Authors>IT Hit LTD.</Authors>
67
<Product>IT Hit User File System</Product>
@@ -9,10 +10,9 @@
910
<ItemGroup>
1011
<PackageReference Include="log4net" Version="2.0.12" />
1112
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
12-
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
1313
</ItemGroup>
1414
<ItemGroup>
15-
<PackageReference Include="ITHit.FileSystem.Windows" Version="3.3.9602.0" />
15+
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.0.10295.0-Beta" />
1616
<ProjectReference Include="..\..\Common\Common.csproj" />
1717
</ItemGroup>
1818
</Project>

Windows/Common/ExternalDataManager.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,18 +442,12 @@ private async Task ShowCustomColumnsAsync(IEnumerable<FileSystemItemPropertyData
442442
}
443443
}
444444

445-
// This method may be called on temp files, typically created by MS Office, that exist for a short period of time.
446-
IStorageItem storageItem = await FsPath.GetStorageItemAsync(userFileSystemPath);
447-
if (storageItem == null)
445+
FileInfo file = new FileInfo(userFileSystemPath);
446+
if(!file.Exists)
448447
{
449-
// This method may be called on temp files, typically created by MS Office, that exist for a short period of time.
450-
// StorageProviderItemProperties.SetAsync(null,) causes AccessViolationException
451-
// which is not handled by .NET (nor handled by HandleProcessCorruptedStateExceptions) and causes a fatal crush.
452448
return;
453449
}
454450

455-
FileInfo file = new FileInfo(userFileSystemPath);
456-
457451
// Can not set provider properties on read-only files.
458452
// Changing read-only attribute on folders triggers folders listing. Changing on files only.
459453
bool readOnly = file.IsReadOnly;
@@ -462,7 +456,16 @@ private async Task ShowCustomColumnsAsync(IEnumerable<FileSystemItemPropertyData
462456
if (readOnly && ((file.Attributes & System.IO.FileAttributes.Directory) == 0))
463457
{
464458
file.IsReadOnly = false;
465-
//new FileInfo(userFileSystemPath).Attributes &= ~System.IO.FileAttributes.ReadOnly;
459+
}
460+
461+
// This method may be called on temp files, typically created by MS Office, that exist for a short period of time.
462+
IStorageItem storageItem = await FsPath.GetStorageItemAsync(userFileSystemPath);
463+
if (storageItem == null)
464+
{
465+
// This method may be called on temp files, typically created by MS Office, that exist for a short period of time.
466+
// StorageProviderItemProperties.SetAsync(null,) causes AccessViolationException
467+
// which is not handled by .NET (nor handled by HandleProcessCorruptedStateExceptions) and causes a fatal crush.
468+
return;
466469
}
467470

468471
// Update columns data.
@@ -472,7 +475,6 @@ private async Task ShowCustomColumnsAsync(IEnumerable<FileSystemItemPropertyData
472475
if (readOnly && ((file.Attributes & System.IO.FileAttributes.Directory) == 0))
473476
{
474477
file.IsReadOnly = true;
475-
//new FileInfo(userFileSystemPath).Attributes |= System.IO.FileAttributes.ReadOnly;
476478
}
477479
}
478480

Windows/Common/Logger.cs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Threading;
66

77
using ITHit.FileSystem;
8+
using ITHit.FileSystem.Windows;
9+
using System.Runtime.InteropServices;
810

911
namespace ITHit.FileSystem.Samples.Common.Windows
1012
{
@@ -35,19 +37,47 @@ public Logger(string componentName, ILog logger)
3537
}
3638

3739
/// <inheritdoc/>
38-
public void LogError(string message, string sourcePath = null, string targetPath = null, Exception ex = null)
40+
public void LogError(string message, string sourcePath = null, string targetPath = null, Exception ex = null, IOperationContext operationContext = null)
3941
{
4042
string att = FsPath.Exists(sourcePath) ? FsPath.GetAttString(sourcePath) : null;
41-
Log.Error($"\n{DateTimeOffset.Now} [{Thread.CurrentThread.ManagedThreadId,2}] {componentName,-26}{message,-45} {sourcePath,-80} {att} ", ex);
43+
string process = null;
44+
byte? priorityHint = null;
45+
long? clientFileId = null;
46+
string serverItemId = null;
47+
48+
if (operationContext != null)
49+
{
50+
ProcessInfo processInfo = Marshal.PtrToStructure<ProcessInfo>(operationContext.ProcessInfo);
51+
process = System.IO.Path.GetFileName(processInfo.ImagePath);
52+
priorityHint = operationContext.PriorityHint;
53+
clientFileId = (operationContext as IWindowsOperationContext).FileId;
54+
//serverItemId = Convert.ToBase64String(operationContext.ItemId);
55+
}
56+
57+
Log.Error($"\n{DateTimeOffset.Now.ToString("hh:mm:ss.fff")} [{process,-25}] {priorityHint,2} {componentName,-26}{message,-45} {sourcePath,-80} {att} ", ex);
4258
}
4359

4460
/// <inheritdoc/>
45-
public void LogMessage(string message, string sourcePath = null, string targetPath = null)
61+
public void LogMessage(string message, string sourcePath = null, string targetPath = null, IOperationContext operationContext = null)
4662
{
4763
string att = FsPath.Exists(sourcePath) ? FsPath.GetAttString(sourcePath) : null;
48-
string size = FsPath.Size(sourcePath);
64+
string process = null;
65+
byte? priorityHint = null;
66+
long? clientFileId = null;
67+
string serverItemId = null;
68+
string size = null;
69+
70+
if (operationContext != null)
71+
{
72+
ProcessInfo processInfo = Marshal.PtrToStructure<ProcessInfo>(operationContext.ProcessInfo);
73+
process = System.IO.Path.GetFileName(processInfo.ImagePath);
74+
priorityHint = operationContext.PriorityHint;
75+
clientFileId = (operationContext as IWindowsOperationContext).FileId;
76+
size = FsPath.FormatBytes((operationContext as IWindowsOperationContext).FileSize);
77+
//serverItemId = Convert.ToBase64String(operationContext.ItemId);
78+
}
4979

50-
Log.Debug($"\n{DateTimeOffset.Now} [{Thread.CurrentThread.ManagedThreadId,2}] {componentName,-26}{message,-45} {sourcePath,-80} {size,7} {att} {targetPath}");
80+
Log.Debug($"\n{DateTimeOffset.Now.ToString("hh:mm:ss.fff")} [{process,-25}] {priorityHint,2} {componentName,-26}{message,-45} {sourcePath,-80} {size,7} {att} {targetPath}");
5181
}
5282
}
5383
}
Binary file not shown.

Windows/VirtualDrive/VirtualDrive.Package/VirtualDrive.Package.wapproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
4444
<PropertyGroup>
4545
<ProjectGuid>9cc25823-7d6c-4aaa-95a0-ee0514ccabd9</ProjectGuid>
46-
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
47-
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
46+
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
47+
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
4848
<DefaultLanguage>en-US</DefaultLanguage>
4949
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
5050
<EntryPointProjectUniqueName>..\VirtualDrive\VirtualDrive.csproj</EntryPointProjectUniqueName>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

Windows/VirtualDrive/VirtualDrive/VirtualDrive.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
55
<CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata>
66
<Authors>IT Hit LTD.</Authors>
77
<Company>IT Hit LTD.</Company>
@@ -29,7 +29,7 @@ This is an advanced project with ETags support, Microsoft Office documents editi
2929
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
3030
</ItemGroup>
3131
<ItemGroup>
32-
<PackageReference Include="ITHit.FileSystem.Windows" Version="3.3.9602.0" />
32+
<PackageReference Include="ITHit.FileSystem.Windows" Version="4.0.10295.0-Beta" />
3333
<ProjectReference Include="..\..\Common\Common.Windows.csproj" />
3434
</ItemGroup>
3535
<ItemGroup>

Windows/VirtualDrive/VirtualDrive/VirtualEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ public override async Task StopAsync()
120120

121121
private void Engine_Message(IEngine sender, EngineMessageEventArgs e)
122122
{
123-
logger.LogMessage(e.Message, e.SourcePath, e.TargetPath);
123+
logger.LogMessage(e.Message, e.SourcePath, e.TargetPath, e.OperationContext);
124124
}
125125

126126
private void Engine_Error(IEngine sender, EngineErrorEventArgs e)
127127
{
128-
logger.LogError(e.Message, e.SourcePath, e.TargetPath, e.Exception);
128+
logger.LogError(e.Message, e.SourcePath, e.TargetPath, e.Exception, e.OperationContext);
129129
}
130130

131131
/// <summary>

Windows/VirtualDrive/VirtualDrive/VirtualFile.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public VirtualFile(string path, VirtualEngine engine, ILogger logger) : base(pat
3030
/// <inheritdoc/>
3131
public async Task OpenAsync(IOperationContext operationContext, IResultContext context)
3232
{
33-
Logger.LogMessage($"{nameof(IFile)}.{nameof(OpenAsync)}()", UserFileSystemPath);
33+
Logger.LogMessage($"{nameof(IFile)}.{nameof(OpenAsync)}()", UserFileSystemPath, default, operationContext);
3434
}
3535

3636
/// <inheritdoc/>
3737
public async Task CloseAsync(IOperationContext operationContext, IResultContext context)
3838
{
39-
Logger.LogMessage($"{nameof(IFile)}.{nameof(CloseAsync)}()", UserFileSystemPath);
39+
Logger.LogMessage($"{nameof(IFile)}.{nameof(CloseAsync)}()", UserFileSystemPath, default, operationContext);
4040
}
4141

4242
/// <inheritdoc/>
@@ -45,7 +45,7 @@ public async Task ReadAsync(Stream output, long offset, long length, ITransferD
4545
// On Windows this method has a 60 sec timeout.
4646
// To process longer requests and reset the timout timer call the resultContext.ReportProgress() or resultContext.ReturnData() method.
4747

48-
Logger.LogMessage($"{nameof(IFile)}.{nameof(ReadAsync)}({offset}, {length})", UserFileSystemPath);
48+
Logger.LogMessage($"{nameof(IFile)}.{nameof(ReadAsync)}({offset}, {length})", UserFileSystemPath, default, operationContext);
4949

5050
SimulateNetworkDelay(length, resultContext);
5151

@@ -63,7 +63,7 @@ public async Task ValidateDataAsync(long offset, long length, IValidateDataOpera
6363
// This method has a 60 sec timeout.
6464
// To process longer requests and reset the timout timer call the ReturnValidationResult() method or IContextWindows.ReportProgress() method.
6565

66-
Logger.LogMessage($"{nameof(IFile)}.{nameof(ValidateDataAsync)}({offset}, {length})", UserFileSystemPath);
66+
Logger.LogMessage($"{nameof(IFile)}.{nameof(ValidateDataAsync)}({offset}, {length})", UserFileSystemPath, default, operationContext);
6767

6868
//SimulateNetworkDelay(length, resultContext);
6969

@@ -73,14 +73,14 @@ public async Task ValidateDataAsync(long offset, long length, IValidateDataOpera
7373
}
7474

7575
/// <inheritdoc/>
76-
public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null)
76+
public async Task WriteAsync(IFileMetadata fileMetadata, Stream content = null, IOperationContext operationContext = null)
7777
{
7878
if(MsOfficeHelper.IsMsOfficeLocked(UserFileSystemPath)) // Required for PowerPoint. It does not block the for writing.
7979
{
8080
throw new ClientLockFailedException("The file is blocked for writing.");
8181
}
8282

83-
Logger.LogMessage($"{nameof(IFile)}.{nameof(WriteAsync)}()", UserFileSystemPath);
83+
Logger.LogMessage($"{nameof(IFile)}.{nameof(WriteAsync)}()", UserFileSystemPath, default, operationContext);
8484

8585
ExternalDataManager customDataManager = Engine.CustomDataManager(UserFileSystemPath);
8686
// Send the ETag to the server as part of the update to ensure the file in the remote storge is not modified since last read.

0 commit comments

Comments
 (0)