Skip to content

Commit 8bdeece

Browse files
committed
v1.2.3941.0
1 parent 93f1615 commit 8bdeece

17 files changed

+94
-48
lines changed

VirtualFileSystem/Framework/Syncronyzation/ClientToServerSync.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace VirtualFileSystem.Syncronyzation
1717
/// <summary>
1818
/// User File System to Remote Storage synchronization.
1919
/// </summary>
20+
/// <remarks>In most cases you can use this class in your project without any changes.</remarks>
2021
internal class ClientToServerSync : Logger
2122
{
2223
/// <summary>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace VirtualFileSystem.Syncronyzation
6+
{
7+
8+
/// <summary>
9+
/// File attributes that are not provided by .NET, but required for
10+
/// detecting pinned/unpinned files and synchronization.
11+
/// </summary>
12+
/// <remarks>
13+
/// You can enable Attributes column in Windows File Manager to see them.
14+
/// Some usefull file attributes reference:
15+
///
16+
/// 4194304 (0x400000) FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS (M)
17+
/// 4096 (0x1000) FILE_ATTRIBUTE_OFFLINE (O)
18+
/// 1024 (0x400) FILE_ATTRIBUTE_REPARSE_POINT (L)
19+
/// 16 (0x10) FILE_ATTRIBUTE_DIRECTORY (D)
20+
/// (0x00080000) FILE_ATTRIBUTE_PINNED (P)
21+
/// (0x00100000) FILE_ATTRIBUTE_UNPINNED (U)
22+
/// 32 (0x20) FILE_ATTRIBUTE_ARCHIVE (A)
23+
/// 512 (0x200) FILE_ATTRIBUTE_SPARSE_FILE
24+
/// </remarks>
25+
[Flags]
26+
public enum FileAttributesExt
27+
{
28+
Pinned = 0x00080000,
29+
Unpinned = 0x00100000,
30+
Offline = 0x1000
31+
}
32+
}

VirtualFileSystem/Framework/Syncronyzation/FullSyncService.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,13 @@
1414

1515
namespace VirtualFileSystem.Syncronyzation
1616
{
17-
18-
// 4194304 (0x400000) FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS (M)
19-
// 4096 (0x1000) FILE_ATTRIBUTE_OFFLINE (O)
20-
// 1024 (0x400) FILE_ATTRIBUTE_REPARSE_POINT (L)
21-
// 16 (0x10) FILE_ATTRIBUTE_DIRECTORY (D)
22-
// (0x00080000) FILE_ATTRIBUTE_PINNED (P)
23-
// (0x00100000) FILE_ATTRIBUTE_UNPINNED (U)
24-
// 32 (0x20) FILE_ATTRIBUTE_ARCHIVE (A)
25-
// 512 (0x200) FILE_ATTRIBUTE_SPARSE_FILE
26-
27-
[Flags]
28-
public enum FileAttributesExt
29-
{
30-
Pinned = 0x00080000,
31-
Unpinned = 0x00100000,
32-
Offline = 0x1000
33-
}
34-
3517
/// <summary>
36-
/// Doing full synchronization between client and server.
18+
/// Doing full synchronization between the user file system and the remote storage, recursively going through all folders.
3719
/// </summary>
3820
/// <remarks>
3921
/// This is a simple full synchronyzation example.
22+
///
23+
/// You can use this class in your project out of the box or replace with a more advanced algorithm.
4024
/// </remarks>
4125
internal class FullSyncService : Logger, IDisposable
4226
{

VirtualFileSystem/Framework/Syncronyzation/RemoteStorageRawItem.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
namespace VirtualFileSystem.Syncronyzation
1111
{
1212
/// <summary>
13-
/// Provides methods for synching user file system to remote storage.
14-
/// Creates, updates and delets files and folders based on the info from user file system.
15-
/// Sets status icons in file manager.
13+
/// Provides methods for synching the user file system to the remote storage.
14+
/// Creates, updates, deletes, moves, locks and unloacks files and folders based on the info from user file system.
15+
/// This class also іets status icons in file manager.
1616
/// </summary>
17+
/// <remarks>In most cases you can use this class in your project without any changes.</remarks>
1718
public class RemoteStorageRawItem
1819
{
1920
/// <summary>
@@ -46,14 +47,19 @@ internal RemoteStorageRawItem(string userFileSystemPath, ILogger logger)
4647
this.logger = logger;
4748
}
4849

50+
/// <summary>
51+
/// Creates a new file or folder in the remote storage.
52+
/// </summary>
53+
/// <param name="userFileSystemNewItemPath">Path to the file or folder in the user file system to be created in the remote storage.</param>
54+
/// <param name="logger">Logger</param>
4955
public static async Task CreateAsync(string userFileSystemNewItemPath, ILogger logger)
5056
{
5157
try
5258
{
53-
logger.LogMessage("Creating item in remote storage", userFileSystemNewItemPath);
59+
logger.LogMessage("Creating item in the remote storage", userFileSystemNewItemPath);
5460
await new RemoteStorageRawItem(userFileSystemNewItemPath, logger).CreateOrUpdateAsync(FileMode.CreateNew);
5561
await new UserFileSystemRawItem(userFileSystemNewItemPath).ClearStateAsync();
56-
logger.LogMessage("Created item in remote storage succesefully", userFileSystemNewItemPath);
62+
logger.LogMessage("Created item in the remote storage succesefully", userFileSystemNewItemPath);
5763
}
5864
catch (Exception ex)
5965
{
@@ -354,7 +360,7 @@ internal async Task<bool> DeleteAsync()
354360
}
355361

356362
/// <summary>
357-
/// Locks file in the remote storage.
363+
/// Locks the file in the remote storage.
358364
/// </summary>
359365
/// <param name="lockMode">
360366
/// Indicates automatic or manual lock.
@@ -371,7 +377,7 @@ internal async Task LockAsync(LockMode lockMode = LockMode.Manual)
371377
}
372378

373379
/// <summary>
374-
/// Locks file in the remote storage or gets existing lock.
380+
/// Locks the file in the remote storage or gets existing lock.
375381
/// </summary>
376382
/// <param name="lockFileOpenMode">
377383
/// Indicates if a new lock should be created or existing lock file to be opened.
@@ -415,7 +421,7 @@ private async Task<Lock> LockAsync(FileMode lockFileOpenMode, LockMode lockMode
415421
/// <summary>
416422
/// Unlocks the file in the remote storage.
417423
/// </summary>
418-
private async Task UnlockAsync()
424+
internal async Task UnlockAsync()
419425
{
420426
using (Lock fileLock = await LockAsync(FileMode.Open))
421427
{
@@ -424,7 +430,7 @@ private async Task UnlockAsync()
424430
}
425431

426432
/// <summary>
427-
/// Unlocks the file in the remote storage.
433+
/// Unlocks the file in the remote storage using existing <see cref="Lock"/>.
428434
/// </summary>
429435
/// <param name="fileLock">File lock.</param>
430436
private async Task UnlockAsync(Lock fileLock)

VirtualFileSystem/ServerToClientSync.cs renamed to VirtualFileSystem/Framework/Syncronyzation/ServerToClientSync.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace VirtualFileSystem.Syncronyzation
1717
/// <summary>
1818
/// Synchronizes files and folders from remote storage to user file system.
1919
/// </summary>
20+
/// <remarks>In most cases you can use this class in your project without any changes.</remarks>
2021
internal class ServerToClientSync : Logger
2122
{
2223
/// <summary>

VirtualFileSystem/Framework/Syncronyzation/UserFileSystemMonitor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ namespace VirtualFileSystem.Syncronyzation
2121
/// <remarks>
2222
/// Windows does not provide any notifications for pinned/unpinned attributes change as well as for files/folders creation.
2323
/// We need to monitor them using regular FileSystemWatcher.
24+
///
25+
/// In most cases you can use this class in your project without any changes.
2426
/// </remarks>
2527
internal class UserFileSystemMonitor : Logger, IDisposable
2628
{

VirtualFileSystem/Framework/Syncronyzation/UserFileSystemRawItem.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
namespace VirtualFileSystem.Syncronyzation
1515
{
1616
/// <summary>
17-
/// Provides methods for synching from remote storage to user file system.
18-
/// Creates, updates and delets placeholder files and folders based on the info from remote storage.
17+
/// Provides methods for synching the from remote storage to the user file system.
18+
/// Creates, updates and deletes placeholder files and folders based on the info from the remote storage.
1919
/// </summary>
20+
/// <remarks>In most cases you can use this class in your project without any changes.</remarks>
2021
internal class UserFileSystemRawItem
2122
{
2223
/// <summary>

VirtualFileSystem/Framework/VfsEngine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace VirtualFileSystem
1515
{
16+
// In most cases you can use this class in your project without any changes.
1617
/// <inheritdoc/>
1718
internal class VfsEngine : EngineWindows
1819
{

VirtualFileSystem/Framework/VfsFile.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace VirtualFileSystem
1313
{
14+
// In most cases you can use this class in your project without any changes.
1415
/// <inheritdoc cref="IFile"/>
1516
internal class VfsFile : VfsFileSystemItem, IFile
1617
{
@@ -81,8 +82,16 @@ public async Task CloseAsync(IOperationContext operationContext, IResultContext
8182

8283
try
8384
{
84-
// Send content to remote storage. Unlock if auto-locked.
85-
await new RemoteStorageRawItem(userFileSystemFilePath, Logger).UpdateAsync();
85+
if (PlaceholderItem.GetItem(userFileSystemFilePath).IsNew())
86+
{
87+
// Create new file in the remote storage.
88+
await RemoteStorageRawItem.CreateAsync(userFileSystemFilePath, Logger);
89+
}
90+
else
91+
{
92+
// Send content to remote storage. Unlock if auto-locked.
93+
await new RemoteStorageRawItem(userFileSystemFilePath, Logger).UpdateAsync();
94+
}
8695
}
8796
catch (IOException ex)
8897
{

VirtualFileSystem/Framework/VfsFileSystemItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace VirtualFileSystem
1414
{
15+
// In most cases you can use this class in your project without any changes.
1516
///<inheritdoc>
1617
internal abstract class VfsFileSystemItem : IFileSystemItem
1718
{

0 commit comments

Comments
 (0)