Skip to content

Commit f41a7c5

Browse files
committed
Start watching for source folder events before doing initial sync in order to handle file updates taking place during initial sync.
1 parent d9a56c5 commit f41a7c5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Program.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private static async Task MainTask()
148148
//Console.WriteLine(Environment.Is64BitProcess ? "x64 version" : "x86 version");
149149
Console.WriteLine("Press Ctrl+C to stop the monitors.");
150150

151-
// start the monitor.
151+
//start the monitor.
152152
using (var watch = new Watcher())
153153
{
154154
//var drvs = System.IO.DriveInfo.GetDrives();
@@ -169,13 +169,19 @@ private static async Task MainTask()
169169
var consoleWatch = new ConsoleWatch(watch);
170170

171171

172-
var messageContext = new Context(
173-
eventObj: null,
174-
token: new CancellationToken()
175-
);
172+
//start watching
173+
//NB! start watching before synchronisation
174+
watch.Start();
175+
176176

177177
if (true)
178178
{
179+
var messageContext = new Context(
180+
eventObj: null,
181+
token: new CancellationToken()
182+
);
183+
184+
179185
await ConsoleWatch.AddMessage(ConsoleColor.White, "Doing initial synchronisation...", messageContext);
180186
ConsoleWatch.DoingInitialSync = true; //NB!
181187

@@ -210,15 +216,12 @@ await ConsoleWatch.OnAddedAsync
210216
}
211217

212218

213-
// start watching
214-
watch.Start();
215-
216-
// listen for the Ctrl+C
219+
//listen for the Ctrl+C
217220
WaitForCtrlC();
218221

219222
Console.WriteLine("Stopping...");
220223

221-
// stop everything.
224+
//stop everything.
222225
watch.Stop();
223226

224227
Console.WriteLine("Exiting...");

0 commit comments

Comments
 (0)