File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 77
88use std:: io:: Write ;
99use std:: process;
10+ use std:: str:: FromStr ;
1011use std:: {
1112 env,
1213 fs:: { self , OpenOptions } ,
@@ -136,16 +137,25 @@ fn check_version(config: &Config) -> Option<String> {
136137 let latest_change_id = CONFIG_CHANGE_HISTORY . last ( ) . unwrap ( ) . change_id ;
137138 let warned_id_path = config. out . join ( "bootstrap" ) . join ( ".last-warned-change-id" ) ;
138139
139- if let Some ( id) = config. change_id {
140+ if let Some ( mut id) = config. change_id {
140141 if id == latest_change_id {
141142 return None ;
142143 }
143144
144- if let Ok ( last_warned_id) = fs:: read_to_string ( & warned_id_path) {
145- if latest_change_id. to_string ( ) == last_warned_id {
146- return None ;
145+ // Always try to use `change-id` from .last-warned-change-id first. If it doesn't exist,
146+ // then use the one from the config.toml. This way we never show the same warnings
147+ // more than once.
148+ if let Ok ( t) = fs:: read_to_string ( & warned_id_path) {
149+ let last_warned_id =
150+ usize:: from_str ( & t) . expect ( & format ! ( "{} is corrupted." , warned_id_path. display( ) ) ) ;
151+
152+ // We only use the last_warned_id if it exists in `CONFIG_CHANGE_HISTORY`.
153+ // Otherwise, we may retrieve all the changes if it's not the highest value.
154+ // For better understanding, refer to `change_tracker::find_recent_config_change_ids`.
155+ if CONFIG_CHANGE_HISTORY . iter ( ) . any ( |config| config. change_id == last_warned_id) {
156+ id = last_warned_id;
147157 }
148- }
158+ } ;
149159
150160 let changes = find_recent_config_change_ids ( id) ;
151161
You can’t perform that action at this time.
0 commit comments