@@ -27,6 +27,11 @@ impl WatchMode {
2727 target_mode : TargetMode :: TrackPath ,
2828 }
2929 }
30+
31+ pub ( crate ) fn upgrade_with ( & mut self , other : WatchMode ) {
32+ self . recursive_mode = self . recursive_mode . upgraded_with ( other. recursive_mode ) ;
33+ self . target_mode = self . target_mode . upgraded_with ( other. target_mode ) ;
34+ }
3035}
3136
3237/// Indicates whether only the provided directory or its sub-directories as well should be watched
@@ -46,6 +51,19 @@ impl RecursiveMode {
4651 RecursiveMode :: NonRecursive => false ,
4752 }
4853 }
54+
55+ pub ( crate ) fn upgraded_with ( self , other : Self ) -> Self {
56+ match self {
57+ RecursiveMode :: Recursive => self ,
58+ RecursiveMode :: NonRecursive => {
59+ if other == RecursiveMode :: Recursive {
60+ other
61+ } else {
62+ self
63+ }
64+ }
65+ }
66+ }
4967}
5068
5169/// Indicates what happens when the relationship of the physical entity and the file path changes
@@ -57,7 +75,7 @@ pub enum TargetMode {
5775 /// (e.g., by a move/rename operation), the watch continues to monitor the new entity
5876 /// that now occupies the path.
5977 ///
60- /// TODO: This is not yet implemented. Currently, all backends behave as NoTrack.
78+ /// TODO: This is not yet implemented. Currently, all backends expect for inotify behave as NoTrack.
6179 TrackPath ,
6280
6381 /// Does not track the file path, nor the physical entity.
@@ -67,6 +85,21 @@ pub enum TargetMode {
6785 NoTrack ,
6886}
6987
88+ impl TargetMode {
89+ pub ( crate ) fn upgraded_with ( self , other : Self ) -> Self {
90+ match self {
91+ TargetMode :: TrackPath => self ,
92+ TargetMode :: NoTrack => {
93+ if other == TargetMode :: TrackPath {
94+ other
95+ } else {
96+ self
97+ }
98+ }
99+ }
100+ }
101+ }
102+
70103/// Watcher Backend configuration
71104///
72105/// This contains multiple settings that may relate to only one specific backend,
0 commit comments