@@ -507,6 +507,7 @@ func fsEventsCallback(cb *streamCallback, payload *fsEventsCallbackPayload) {
507507 if path == "" {
508508 continue
509509 }
510+ comparison := comparisonPath {path : path }
510511
511512 isRemoved := flag & flagItemRemoved != 0
512513 isRenamed := flag & flagItemRenamed != 0
@@ -527,7 +528,7 @@ func fsEventsCallback(cb *streamCallback, payload *fsEventsCallbackPayload) {
527528 if watch .state .terminated .Load () {
528529 continue
529530 }
530- if fseventsOverflowMatches (watch .w , path ) {
531+ if fseventsOverflowMatchesPrepared (watch .w , & comparison ) {
531532 watch .w .events .setError (overflow )
532533 touched [watch .w ] = struct {}{}
533534 }
@@ -551,7 +552,7 @@ func fsEventsCallback(cb *streamCallback, payload *fsEventsCallbackPayload) {
551552 continue
552553 }
553554 w := watch .w
554- displayPath , ok := fseventsDisplayPath (w , rawPath )
555+ displayPath , ok := fseventsDisplayPathPrepared (w , & comparison )
555556 if ! ok {
556557 continue
557558 }
@@ -623,18 +624,42 @@ func fsEventsCallback(cb *streamCallback, payload *fsEventsCallbackPayload) {
623624}
624625
625626func fseventsDisplayPath (w * dirWatch , rawPath string ) (string , bool ) {
626- if isInDirectoryOrSelf (w .physicalDir , rawPath ) {
627- return w .displayPath (rawPath ), true
627+ path := comparisonPath {path : rawPath }
628+ return fseventsDisplayPathPrepared (w , & path )
629+ }
630+
631+ func fseventsDisplayPathPrepared (w * dirWatch , rawPath * comparisonPath ) (string , bool ) {
632+ physical := comparisonPath {path : w .physicalDir , folded : w .physicalDirFold , ready : w .physicalDirFold != "" }
633+ if path , ok := w .comparer .rebasePrepared (rawPath , physical , w .dir ); ok {
634+ return path , true
628635 }
629- if w .physicalDir != w .dir && isInDirectoryOrSelf (w .dir , rawPath ) {
630- return rawPath , true
636+ if w .physicalDir != w .dir {
637+ logical := comparisonPath {path : w .dir , folded : w .dirFold , ready : w .dirFold != "" }
638+ return w .comparer .rebasePrepared (rawPath , logical , w .dir )
631639 }
632640 return "" , false
633641}
634642
635643func fseventsOverflowMatches (w * dirWatch , rawPath string ) bool {
636- if isInDirectoryOrSelf (w .physicalDir , rawPath ) || isInDirectoryOrSelf (rawPath , w .physicalDir ) {
644+ path := comparisonPath {path : rawPath }
645+ return fseventsOverflowMatchesPrepared (w , & path )
646+ }
647+
648+ func fseventsOverflowMatchesPrepared (w * dirWatch , rawPath * comparisonPath ) bool {
649+ physical := comparisonPath {path : w .physicalDir , folded : w .physicalDirFold , ready : w .physicalDirFold != "" }
650+ if _ , ok := w .comparer .suffixPrepared (physical , rawPath ); ok {
637651 return true
638652 }
639- return w .physicalDir != w .dir && (isInDirectoryOrSelf (w .dir , rawPath ) || isInDirectoryOrSelf (rawPath , w .dir ))
653+ if _ , ok := w .comparer .suffixPrepared (* rawPath , & physical ); ok {
654+ return true
655+ }
656+ if w .physicalDir != w .dir {
657+ logical := comparisonPath {path : w .dir , folded : w .dirFold , ready : w .dirFold != "" }
658+ if _ , ok := w .comparer .suffixPrepared (logical , rawPath ); ok {
659+ return true
660+ }
661+ _ , ok := w .comparer .suffixPrepared (* rawPath , & logical )
662+ return ok
663+ }
664+ return false
640665}
0 commit comments