diff --git a/src/main.rs b/src/main.rs index 43b67bd..3c46d07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,7 +119,7 @@ fn check_files_to_keep(config: &Config, files: &[FileName]) -> Result Result {start_of_chunk}"); loop { @@ -160,18 +160,24 @@ fn check_files_to_keep(config: &Config, files: &[FileName]) -> Result end_of_chunk { - trace!("{file} is in chunk. beaten by {chunk_file_to_keep:?}"); - chunk_file_to_keep.get_or_insert(file); + if !found_file_for_chunk { + keep_files.insert(file); + found_file_for_chunk = true; + trace!("{file} is in chunk. keeping."); + } else { + trace!("{file} is in chunk. beaten by another file"); + } } else { - trace!("reached end of chunk"); files.push(file); // put the file back in the queue - break; - } - } - if let Some(file) = chunk_file_to_keep { - trace!("keeping files {file}"); - keep_files.insert(file); + if file < period_end { + trace!("reached end of period"); + continue 'period; + } else { + trace!("reached end of chunk"); + break; + } + } } }