|
2 | 2 | using System.IO; |
3 | 3 | using System.Threading.Tasks; |
4 | 4 | using FileProvider; |
| 5 | +using ITHit.FileSystem; |
5 | 6 |
|
6 | 7 | namespace FileProviderExtension |
7 | 8 | { |
@@ -32,16 +33,13 @@ public class RemoteStorageMonitor |
32 | 33 | /// </summary> |
33 | 34 | private FileSystemWatcher watcher = new FileSystemWatcher(); |
34 | 35 |
|
35 | | - /// <summary> |
36 | | - /// File provider manager for signals an update to virtual system. |
37 | | - /// </summary> |
38 | | - private NSFileProviderManager fileProviderManager; |
| 36 | + private IEngine engine; |
39 | 37 |
|
40 | | - public RemoteStorageMonitor(string remoteStorageRootPath, NSFileProviderManager fileProviderManager) |
| 38 | + public RemoteStorageMonitor(string remoteStorageRootPath, IEngine engine) |
41 | 39 | { |
42 | 40 | this.remoteStorageRootPath = remoteStorageRootPath; |
43 | 41 | this.logger = new ConsoleLogger(GetType().Name); |
44 | | - this.fileProviderManager = fileProviderManager; |
| 42 | + this.engine = engine; |
45 | 43 | } |
46 | 44 |
|
47 | 45 | /// <summary> |
@@ -76,59 +74,28 @@ private void RenamedAsync(object sender, RenamedEventArgs e) |
76 | 74 | { |
77 | 75 | logger.LogMessage(e.ChangeType.ToString(), e.FullPath); |
78 | 76 |
|
79 | | - string userFileSystemParentPath = Path.GetDirectoryName(e.FullPath); |
80 | | - logger.LogMessage(e.ChangeType.ToString(), Mapping.ReverseMapPath(userFileSystemParentPath)); |
81 | | - |
82 | | - fileProviderManager.SignalEnumerator(Mapping.ReverseMapPath(userFileSystemParentPath), error => { |
83 | | - if (error != null) |
84 | | - { |
85 | | - logger.LogError(error.Description); |
86 | | - } |
87 | | - }); |
88 | | - |
| 77 | + engine.ServerNotifications(Mapping.ReverseMapPath(e.OldFullPath)).MoveToAsync(e.FullPath); |
89 | 78 | } |
90 | 79 |
|
91 | 80 | private void DeletedAsync(object sender, FileSystemEventArgs e) |
92 | 81 | { |
93 | 82 | logger.LogMessage(e.ChangeType.ToString(), e.FullPath); |
94 | | - string userFileSystemParentPath = Path.GetDirectoryName(e.FullPath); |
95 | | - logger.LogMessage(e.ChangeType.ToString(), Mapping.ReverseMapPath(userFileSystemParentPath)); |
96 | | - |
97 | | - fileProviderManager.SignalEnumerator(Mapping.ReverseMapPath(userFileSystemParentPath), error => { |
98 | | - if (error != null) |
99 | | - { |
100 | | - logger.LogError(error.Description); |
101 | | - } |
102 | | - }); |
| 83 | + |
| 84 | + engine.ServerNotifications(Mapping.ReverseMapPath(e.FullPath)).DeleteAsync(); |
103 | 85 | } |
104 | 86 |
|
105 | 87 | private void CreatedAsync(object sender, FileSystemEventArgs e) |
106 | 88 | { |
107 | 89 | logger.LogMessage(e.ChangeType.ToString(), e.FullPath); |
108 | | - string userFileSystemParentPath = Path.GetDirectoryName(e.FullPath); |
109 | | - logger.LogMessage(e.ChangeType.ToString(), Mapping.ReverseMapPath(userFileSystemParentPath)); |
110 | | - |
111 | | - fileProviderManager.SignalEnumerator(Mapping.ReverseMapPath(userFileSystemParentPath), error => { |
112 | | - if (error != null) |
113 | | - { |
114 | | - logger.LogError(error.Description); |
115 | | - } |
116 | | - }); |
117 | | - |
118 | | - |
| 90 | + |
| 91 | + engine.ServerNotifications(Mapping.ReverseMapPath(e.FullPath)).CreateAsync(null); |
119 | 92 | } |
120 | 93 |
|
121 | 94 | private void ChangedAsync(object sender, FileSystemEventArgs e) |
122 | 95 | { |
123 | 96 | logger.LogMessage(e.ChangeType.ToString(), e.FullPath); |
124 | | - string remoteStoragePath = e.FullPath; |
125 | | - |
126 | | - //fileProviderManager.SignalEnumerator(Mapping.ReverseMapPath(remoteStoragePath), error => { |
127 | | - // if (error != null) |
128 | | - // { |
129 | | - // logger.LogError(error.Description); |
130 | | - // } |
131 | | - //}); |
| 97 | + |
| 98 | + engine.ServerNotifications(Mapping.ReverseMapPath(e.FullPath)).UpdateAsync(null); |
132 | 99 | } |
133 | 100 |
|
134 | 101 | private void Error(object sender, ErrorEventArgs e) |
|
0 commit comments