@@ -34,11 +34,12 @@ internal static class Global
3434 public static List < string > ExcludedExtensions = new List < string > ( ) { "*~" , "tmp" } ;
3535 public static List < string > IgnorePathsStartingWith = new List < string > ( ) ;
3636 public static List < string > IgnorePathsContaining = new List < string > ( ) ;
37-
38-
37+
3938 public static string AsyncPath = "" ;
4039 public static string SyncPath = "" ;
4140
41+ public static bool Bidirectional = true ;
42+
4243
4344
4445 internal static readonly AsyncLockQueueDictionary FileOperationLocks = new AsyncLockQueueDictionary ( ) ;
@@ -109,6 +110,8 @@ private static void Main()
109110
110111 var fileConfig = config . GetSection ( "Files" ) ;
111112
113+ Global . Bidirectional = fileConfig [ "Bidirectional" ] ? . ToUpperInvariant ( ) != "FALSE" ; //default is true
114+
112115 Global . AsyncPath = fileConfig [ "AsyncPath" ] ;
113116 Global . SyncPath = fileConfig [ "SyncPath" ] ;
114117
@@ -160,10 +163,13 @@ private static async Task MainTask()
160163 // }
161164 //}
162165
163-
164- watch . Add ( new Request ( Global . AsyncPath , recursive : true ) ) ;
165166 watch . Add ( new Request ( Global . SyncPath , recursive : true ) ) ;
166167
168+ if ( Global . Bidirectional )
169+ {
170+ watch . Add ( new Request ( Global . AsyncPath , recursive : true ) ) ;
171+ }
172+
167173
168174 // prepare the console watcher so we can output pretty messages.
169175 var consoleWatch = new ConsoleWatch ( watch ) ;
@@ -199,15 +205,18 @@ await ConsoleWatch.OnAddedAsync
199205 }
200206 }
201207
202- //2. Do initial synchronisation from async to sync folder //TODO: config for enabling and ordering of this operation
203- foreach ( var fileInfo in new DirectoryInfo ( Global . AsyncPath )
204- . GetFiles ( "*." + Global . WatchedCodeExtension , SearchOption . AllDirectories ) )
208+ if ( Global . Bidirectional )
205209 {
206- await ConsoleWatch . OnAddedAsync
207- (
208- new DummyFileSystemEvent ( fileInfo ) ,
209- new CancellationToken ( )
210- ) ;
210+ //2. Do initial synchronisation from async to sync folder //TODO: config for enabling and ordering of this operation
211+ foreach ( var fileInfo in new DirectoryInfo ( Global . AsyncPath )
212+ . GetFiles ( "*." + Global . WatchedCodeExtension , SearchOption . AllDirectories ) )
213+ {
214+ await ConsoleWatch . OnAddedAsync
215+ (
216+ new DummyFileSystemEvent ( fileInfo ) ,
217+ new CancellationToken ( )
218+ ) ;
219+ }
211220 }
212221
213222
0 commit comments