@@ -81,11 +81,33 @@ impl <'a> SessionInfo<'a> {
81
81
}
82
82
}
83
83
84
- pub fn request_update_file_index ( session : & mut SessionInfo , path : & PathBuf , forced_delay : bool ) {
85
- if !forced_delay && ( session. delayed_process_sender . is_none ( ) || !session. sync_odoo . need_rebuild && session. sync_odoo . config . refresh_mode == RefreshMode :: Adaptive && session. sync_odoo . get_rebuild_queue_size ( ) < 10 ) {
86
- let _ = SyncOdoo :: _unload_path ( session, & path, false ) ;
87
- Odoo :: search_symbols_to_rebuild ( session, & path. sanitize ( ) ) ;
88
- SyncOdoo :: process_rebuilds ( session) ;
84
+ /*
85
+ * Request an update of the file in the index.
86
+ * path: path of the file
87
+ * process_now: indicate if the current action is due to a save action
88
+ * forced_delay: indicate that we want to force a delay
89
+ */
90
+ pub fn request_update_file_index ( session : & mut SessionInfo , path : & PathBuf , is_save : bool , forced_delay : bool ) {
91
+ if ( !forced_delay || session. delayed_process_sender . is_none ( ) ) && !session. sync_odoo . need_rebuild {
92
+ if session. sync_odoo . config . refresh_mode == RefreshMode :: OnSave {
93
+ if is_save {
94
+ let _ = SyncOdoo :: _unload_path ( session, & path, false ) ;
95
+ Odoo :: search_symbols_to_rebuild ( session, & path. sanitize ( ) ) ;
96
+ SyncOdoo :: process_rebuilds ( session) ;
97
+ }
98
+ return ;
99
+ }
100
+ if session. sync_odoo . config . refresh_mode == RefreshMode :: Adaptive &&
101
+ session. sync_odoo . get_rebuild_queue_size ( ) < 10 {
102
+ let _ = SyncOdoo :: _unload_path ( session, & path, false ) ;
103
+ Odoo :: search_symbols_to_rebuild ( session, & path. sanitize ( ) ) ;
104
+ SyncOdoo :: process_rebuilds ( session) ;
105
+ } else {
106
+ if forced_delay {
107
+ session. sync_odoo . watched_file_updates . store ( session. sync_odoo . watched_file_updates . load ( Ordering :: SeqCst ) + 1 , Ordering :: SeqCst ) ;
108
+ }
109
+ let _ = session. delayed_process_sender . as_ref ( ) . unwrap ( ) . send ( DelayedProcessingMessage :: UPDATE_FILE_INDEX ( UpdateFileIndexData { path : path. clone ( ) , time : std:: time:: Instant :: now ( ) , forced_delay} ) ) ;
110
+ }
89
111
} else {
90
112
if forced_delay {
91
113
session. sync_odoo . watched_file_updates . store ( session. sync_odoo . watched_file_updates . load ( Ordering :: SeqCst ) + 1 , Ordering :: SeqCst ) ;
0 commit comments