Skip to content

Commit ca45391

Browse files
committed
v2.0.4465.0
1 parent 1b0e419 commit ca45391

File tree

113 files changed

+2743
-1598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2743
-1598
lines changed

WebDAVDrive/Framework/ClientLockFailedException.cs renamed to ITHit.FileSystem.Samples.Common/ClientLockFailedException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.IO;
44
using System.Text;
55

6-
namespace VirtualFileSystem
6+
namespace ITHit.FileSystem.Samples.Common
77
{
88
/// <summary>
99
/// Thrown when a file can not be locked. For example when a lock-token file is blocked

WebDAVDrive/Framework/CustomData.cs renamed to ITHit.FileSystem.Samples.Common/CustomData.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
using System.Text;
77
using System.Threading.Tasks;
88

9-
namespace VirtualFileSystem
9+
namespace ITHit.FileSystem.Samples.Common
1010
{
1111
/// <summary>
1212
/// Custom data stored with a file or folder placeholder, such original file/folder path. Max 4KB.
1313
/// </summary>
1414
/// <remarks>To avoid storing metatadata and keep footprit small, this class is is using custom serialization.</remarks>
15-
internal class CustomData
15+
public class CustomData
1616
{
1717
/// <summary>
1818
/// Keeps the original file/folder path. Used to sync file/folder from user file system to remote storage
1919
/// if this app was not running when the file/folder was moved or renamed. This field allows to avoid
2020
/// delete-create sequence during client to server synchronization after app failure.
2121
/// </summary>
22-
internal string OriginalPath = "";
22+
public string OriginalPath = "";
2323

2424
/// <summary>
2525
/// Serializes all custom data fields into the byte array.
2626
/// </summary>
2727
/// <returns>Byte array representing custom data.</returns>
28-
internal byte[] Serialize()
28+
public byte[] Serialize()
2929
{
3030
using (MemoryStream m = new MemoryStream())
3131
{
@@ -42,7 +42,7 @@ internal byte[] Serialize()
4242
/// </summary>
4343
/// <param name="data">Byte array representing custom data.</param>
4444
/// <returns></returns>
45-
internal static CustomData Desserialize(byte[] data)
45+
public static CustomData Deserialize(byte[] data)
4646
{
4747
if(data == null)
4848
{
@@ -81,7 +81,7 @@ public static void SetCustomData(Microsoft.Win32.SafeHandles.SafeFileHandle safe
8181
public static void SetOriginalPath(this PlaceholderItem placeholder, string originalPath)
8282
{
8383
byte[] customDataRaw = placeholder.GetCustomData();
84-
CustomData customData = (customDataRaw.Length > 0) ? CustomData.Desserialize(customDataRaw) : new CustomData();
84+
CustomData customData = (customDataRaw.Length > 0) ? CustomData.Deserialize(customDataRaw) : new CustomData();
8585

8686
customData.OriginalPath = originalPath;
8787
placeholder.SetCustomData(customData.Serialize());
@@ -90,7 +90,7 @@ public static void SetOriginalPath(this PlaceholderItem placeholder, string orig
9090
public static string GetOriginalPath(this PlaceholderItem placeholder)
9191
{
9292
byte[] customDataRaw = placeholder.GetCustomData();
93-
CustomData customData = (customDataRaw.Length > 0) ? CustomData.Desserialize(customDataRaw) : new CustomData();
93+
CustomData customData = (customDataRaw.Length > 0) ? CustomData.Deserialize(customDataRaw) : new CustomData();
9494
return customData.OriginalPath;
9595
}
9696

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace VirtualFileSystem
7+
namespace ITHit.FileSystem.Samples.Common
88
{
99
/// <summary>
1010
/// Provides method for reading and writing ETags.
1111
/// </summary>
12-
internal static class ETag
12+
public static class ETag
1313
{
1414
/// <summary>
1515
/// Creates or updates ETag associated with the file.
@@ -56,10 +56,10 @@ public static void DeleteETag(string userFileSystemPath)
5656
public static string GetETagFilePath(string userFileSystemPath)
5757
{
5858
// Get path relative to the virtual root.
59-
string relativePath = Path.TrimEndingDirectorySeparator(userFileSystemPath).Substring(
60-
Path.TrimEndingDirectorySeparator(Program.Settings.UserFileSystemRootPath).Length);
59+
string relativePath = userFileSystemPath.TrimEnd(Path.DirectorySeparatorChar).Substring(
60+
Config.Settings.UserFileSystemRootPath.TrimEnd(Path.DirectorySeparatorChar).Length);
6161

62-
string path = $"{Path.TrimEndingDirectorySeparator(Program.Settings.ServerDataFolderPath)}{relativePath}.etag";
62+
string path = $"{Config.Settings.ServerDataFolderPath.TrimEnd(Path.DirectorySeparatorChar)}{relativePath}.etag";
6363
return path;
6464
}
6565

@@ -73,7 +73,7 @@ public static string GetETagFilePath(string userFileSystemPath)
7373
/// During client->server update it is sent back to the remote storage together with a modified content.
7474
/// This ensures the changes on the server are not overwritten if the document on the server is modified.
7575
/// </remarks>
76-
internal static async Task<bool> ETagEqualsAsync(string userFileSystemPath, FileSystemItemBasicInfo remoteStorageItem)
76+
public static async Task<bool> ETagEqualsAsync(string userFileSystemPath, FileSystemItemBasicInfo remoteStorageItem)
7777
{
7878
string remoteStorageETag = remoteStorageItem.ETag;
7979
string userFileSystemETag = await ETag.GetETagAsync(userFileSystemPath);

WebDAVDrive/Framework/FileBasicInfo.cs renamed to ITHit.FileSystem.Samples.Common/FileBasicInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using System.Collections.Generic;
44
using System.Text;
55

6-
namespace VirtualFileSystem
6+
namespace ITHit.FileSystem.Samples.Common
77
{
88
///<inheritdoc cref="IFileBasicInfo"/>
9-
internal class FileBasicInfo : FileSystemItemBasicInfo, IFileBasicInfo
9+
public class FileBasicInfo : FileSystemItemBasicInfo, IFileBasicInfo
1010
{
1111
///<inheritdoc/>
1212
public long Length { get; set; }

WebDAVDrive/Framework/FileSystemItemBasicInfo.cs renamed to ITHit.FileSystem.Samples.Common/FileSystemItemBasicInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
using System.IO;
55
using System.Text;
66

7-
namespace VirtualFileSystem
7+
namespace ITHit.FileSystem.Samples.Common
88
{
99
/// <summary>
1010
/// Represents a basic information about the file or the folder in the user file system.
1111
/// In addition to properties provided by <see cref="IFileSystemItem"/> this class contains Etag property.
1212
/// </summary>
13-
internal class FileSystemItemBasicInfo : IFileSystemItemBasicInfo
13+
public class FileSystemItemBasicInfo : IFileSystemItemBasicInfo
1414
{
1515
///<inheritdoc/>
1616
public string Name { get; set; }
@@ -42,5 +42,10 @@ internal class FileSystemItemBasicInfo : IFileSystemItemBasicInfo
4242
/// Indicates if the item is locked by another user in the remote storage.
4343
/// </summary>
4444
public bool LockedByAnotherUser { get; set; }
45+
46+
/// <summary>
47+
/// Custom columns data to be displayed in the file manager.
48+
/// </summary>
49+
public IEnumerable<FileSystemItemPropertyData> CustomProperties { get; set; }
4550
}
4651
}

WebDAVDrive/Framework/FolderBasicInfo.cs renamed to ITHit.FileSystem.Samples.Common/FolderBasicInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using System.Collections.Generic;
44
using System.Text;
55

6-
namespace VirtualFileSystem
6+
namespace ITHit.FileSystem.Samples.Common
77
{
88
/// <inheritdoc cref="IFolderBasicInfo"/>
9-
internal class FolderBasicInfo : FileSystemItemBasicInfo, IFolderBasicInfo
9+
public class FolderBasicInfo : FileSystemItemBasicInfo, IFolderBasicInfo
1010
{
1111

1212
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
using System.IO;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using Windows.Storage;
7+
using FileAttributes = System.IO.FileAttributes;
68

7-
namespace VirtualFileSystem
9+
namespace ITHit.FileSystem.Samples.Common
810
{
911
/// <summary>
1012
/// Provides file system operations. Helps determining file and folder existence and creating file and folder items.
@@ -62,15 +64,15 @@ public static bool IsRecycleBin(string path)
6264
/// Instance of <see cref="Windows.Storage.StorageFile"/> or <see cref="Windows.Storage.StorageFolder"/>
6365
/// that corresponds to path or null if item does not exists.
6466
/// </returns>
65-
public static async Task<Windows.Storage.IStorageItem> GetStorageItemAsync(string path)
67+
public static async Task<IStorageItem> GetStorageItemAsync(string path)
6668
{
6769
if (File.Exists(path))
6870
{
69-
return await Windows.Storage.StorageFile.GetFileFromPathAsync(path);
71+
return await StorageFile.GetFileFromPathAsync(path);
7072
}
7173
if (Directory.Exists(path))
7274
{
73-
return await Windows.Storage.StorageFolder.GetFolderFromPathAsync(path);
75+
return await StorageFolder.GetFolderFromPathAsync(path);
7476
}
7577
return null;
7678
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.1</TargetFramework>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageReference Include="ITHit.FileSystem.Windows" Version="2.0.4465.0" />
7+
<PackageReference Include="log4net" Version="2.0.12" />
8+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
9+
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
10+
</ItemGroup>
11+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using ITHit.FileSystem;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
5+
namespace ITHit.FileSystem.Samples.Common
6+
{
7+
public interface IUserFile : IUserFileSystemItem
8+
{
9+
Task<byte[]> ReadAsync(long offset, long length);
10+
Task<string> UpdateAsync(IFileBasicInfo fileInfo, Stream content = null, ServerLockInfo lockInfo = null);
11+
Task<bool> ValidateDataAsync(long offset, long length);
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Threading.Tasks;
2+
3+
namespace ITHit.FileSystem.Samples.Common
4+
{
5+
public interface IUserFileSystemItem
6+
{
7+
Task DeleteAsync();
8+
Task<ServerLockInfo> LockAsync();
9+
Task MoveToAsync(string userFileSystemNewPath);
10+
Task UnlockAsync(string lockToken);
11+
}
12+
}

0 commit comments

Comments
 (0)