@@ -313,7 +313,7 @@ internal class ConsoleWatch
313313 public static bool DoingInitialSync = false ;
314314#pragma warning restore S2223
315315
316- private static ConcurrentDictionary < string , DateTime > ConverterSavedFileDates = new ConcurrentDictionary < string , DateTime > ( ) ;
316+ private static ConcurrentDictionary < string , DateTime > BidirectionalConverterSavedFileDates = new ConcurrentDictionary < string , DateTime > ( ) ;
317317 private static readonly AsyncLockQueueDictionary FileEventLocks = new AsyncLockQueueDictionary ( ) ;
318318
319319
@@ -366,8 +366,10 @@ public static string GetNonFullName(string fullName)
366366 {
367367 return fullName . Substring ( Global . SyncPath . Length ) ;
368368 }
369-
370- throw new ArgumentException ( "fullName" ) ;
369+ else
370+ {
371+ throw new ArgumentException ( "fullName" ) ;
372+ }
371373 }
372374
373375 public static string GetOtherFullName ( string fullName )
@@ -376,11 +378,11 @@ public static string GetOtherFullName(string fullName)
376378
377379 if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
378380 {
379- return Global . SyncPath + nonFullName ;
381+ return Path . Combine ( Global . SyncPath , nonFullName ) ;
380382 }
381383 else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) )
382384 {
383- return Global . AsyncPath + nonFullName ;
385+ return Path . Combine ( Global . AsyncPath , nonFullName ) ;
384386 }
385387 else
386388 {
@@ -427,12 +429,12 @@ public static async Task DeleteFile(string fullName, Context context)
427429 {
428430 await WriteException ( ex , context ) ;
429431 }
430- }
432+ } //public static async Task DeleteFile(string fullName, Context context)
431433
432- public static DateTime GetConverterSaveDate ( string fullName )
434+ public static DateTime GetBidirectionalConverterSaveDate ( string fullName )
433435 {
434436 DateTime converterSaveDate ;
435- if ( ! ConverterSavedFileDates . TryGetValue ( fullName , out converterSaveDate ) )
437+ if ( ! BidirectionalConverterSavedFileDates . TryGetValue ( fullName , out converterSaveDate ) )
436438 {
437439 converterSaveDate = DateTime . MinValue ;
438440 }
@@ -445,7 +447,7 @@ public static bool NeedsUpdate(string fullName)
445447 if ( DoingInitialSync )
446448 return true ;
447449
448- var converterSaveDate = GetConverterSaveDate ( fullName ) ;
450+ var converterSaveDate = GetBidirectionalConverterSaveDate ( fullName ) ;
449451 var fileTime = GetFileTime ( fullName ) ;
450452
451453 if (
@@ -502,7 +504,7 @@ public static async Task FileUpdated(string fullName, Context context)
502504 }
503505 }
504506 }
505- }
507+ } //public static async Task FileUpdated(string fullName, Context context)
506508
507509 private static async Task FileDeleted ( string fullName , Context context )
508510 {
@@ -575,36 +577,36 @@ private static bool IsWatchedFile(string fullName)
575577
576578 return false ;
577579
578- } //private bool IsWatchedFile(string fullName, Context context )
580+ } //private bool IsWatchedFile(string fullName)
579581
580582#pragma warning disable AsyncFixer01
581- private static async Task OnRenamedAsync ( IRenamedFileSystemEvent rfse , CancellationToken token )
583+ private static async Task OnRenamedAsync ( IRenamedFileSystemEvent fse , CancellationToken token )
582584 {
583- var context = new Context ( rfse , token ) ;
585+ var context = new Context ( fse , token ) ;
584586
585587 try
586588 {
587- if ( rfse . IsFile )
589+ if ( fse . IsFile )
588590 {
589- if ( IsWatchedFile ( rfse . PreviousFileSystemInfo . FullName )
590- || IsWatchedFile ( rfse . FileSystemInfo . FullName ) )
591+ if ( IsWatchedFile ( fse . PreviousFileSystemInfo . FullName )
592+ || IsWatchedFile ( fse . FileSystemInfo . FullName ) )
591593 {
592- await AddMessage ( ConsoleColor . Cyan , $ "[{ ( rfse . IsFile ? "F" : "D" ) } ][R]:{ rfse . PreviousFileSystemInfo . FullName } > { rfse . FileSystemInfo . FullName } ", context ) ;
594+ await AddMessage ( ConsoleColor . Cyan , $ "[{ ( fse . IsFile ? "F" : "D" ) } ][R]:{ fse . PreviousFileSystemInfo . FullName } > { fse . FileSystemInfo . FullName } ", context ) ;
593595
594596 //NB! if file is renamed to cs~ or resx~ then that means there will be yet another write to same file, so lets skip this event here
595- if ( ! rfse . FileSystemInfo . FullName . EndsWith ( "~" ) )
597+ if ( ! fse . FileSystemInfo . FullName . EndsWith ( "~" ) )
596598 {
597599 //using (await Global.FileOperationLocks.LockAsync(rfse.FileSystemInfo.FullName, rfse.PreviousFileSystemInfo.FullName, context.Token)) //comment-out: prevent deadlock
598600 {
599- await FileUpdated ( rfse . FileSystemInfo . FullName , context ) ;
600- await FileDeleted ( rfse . PreviousFileSystemInfo . FullName , context ) ;
601+ await FileUpdated ( fse . FileSystemInfo . FullName , context ) ;
602+ await FileDeleted ( fse . PreviousFileSystemInfo . FullName , context ) ;
601603 }
602604 }
603605 }
604606 }
605607 else
606608 {
607- await AddMessage ( ConsoleColor . Cyan , $ "[{ ( rfse . IsFile ? "F" : "D" ) } ][R]:{ rfse . PreviousFileSystemInfo . FullName } > { rfse . FileSystemInfo . FullName } ", context ) ;
609+ await AddMessage ( ConsoleColor . Cyan , $ "[{ ( fse . IsFile ? "F" : "D" ) } ][R]:{ fse . PreviousFileSystemInfo . FullName } > { fse . FileSystemInfo . FullName } ", context ) ;
608610
609611 //TODO trigger update / delete event for all files in new folder
610612 }
@@ -613,7 +615,7 @@ private static async Task OnRenamedAsync(IRenamedFileSystemEvent rfse, Cancellat
613615 {
614616 await WriteException ( ex , context ) ;
615617 }
616- }
618+ } //private static async Task OnRenamedAsync(IRenamedFileSystemEvent fse, CancellationToken token)
617619
618620 private static async Task OnRemovedAsync ( IFileSystemEvent fse , CancellationToken token )
619621 {
@@ -766,7 +768,7 @@ public static async Task SaveFileModifications(string fullName, string fileData,
766768 await FileExtensions . WriteAllTextAsync ( @"\\?\" + otherFullName , fileData , context . Token ) ;
767769
768770 var now = DateTime . UtcNow ; //NB! compute now after saving the file
769- ConverterSavedFileDates [ otherFullName ] = now ;
771+ BidirectionalConverterSavedFileDates [ otherFullName ] = now ;
770772
771773
772774 await AddMessage ( ConsoleColor . Magenta , $ "Synchronised updates from file { fullName } ", context ) ;
@@ -785,9 +787,9 @@ public static async Task SaveFileModifications(string fullName, string fileData,
785787 await ConsoleWatch . WriteException ( ex , context ) ;
786788 }
787789
788- ConverterSavedFileDates [ otherFullName ] = now ;
790+ BidirectionalConverterSavedFileDates [ otherFullName ] = now ;
789791 }
790- }
792+ } //public static async Task SaveFileModifications(string fullName, string fileData, string originalData, Context context)
791793
792794 public static async Task SaveFileModifications ( string fullName , byte [ ] fileData , byte [ ] originalData , Context context )
793795 {
@@ -813,7 +815,7 @@ public static async Task SaveFileModifications(string fullName, byte[] fileData,
813815 await FileExtensions . WriteAllBytesAsync ( @"\\?\" + otherFullName , fileData , context . Token ) ;
814816
815817 var now = DateTime . UtcNow ; //NB! compute now after saving the file
816- ConverterSavedFileDates [ otherFullName ] = now ;
818+ BidirectionalConverterSavedFileDates [ otherFullName ] = now ;
817819
818820
819821 await AddMessage ( ConsoleColor . Magenta , $ "Synchronised updates from file { fullName } ", context ) ;
@@ -832,9 +834,9 @@ public static async Task SaveFileModifications(string fullName, byte[] fileData,
832834 await ConsoleWatch . WriteException ( ex , context ) ;
833835 }
834836
835- ConverterSavedFileDates [ otherFullName ] = now ;
837+ BidirectionalConverterSavedFileDates [ otherFullName ] = now ;
836838 }
837- }
839+ } //public static async Task SaveFileModifications(string fullName, byte[] fileData, byte[] originalData, Context context)
838840
839841#pragma warning restore AsyncFixer01
840842 }
0 commit comments