@@ -924,6 +924,19 @@ logfile::process_prefix(shared_buffer_ref& sbr,
924924 this ->lf_index .back ().set_has_ansi (li.li_utf8_scan_result .usr_has_ansi );
925925 }
926926
927+ if (this ->lf_format != nullptr
928+ && this ->lf_index .back ().get_time <std::chrono::microseconds>()
929+ > this ->lf_options .loo_time_range .tr_end )
930+ {
931+ if (!this ->lf_upper_bound_size ) {
932+ this ->lf_upper_bound_size = this ->lf_index .back ().get_offset ();
933+ log_debug (" %s: upper found in file found %llu" ,
934+ this ->lf_filename_as_string .c_str (),
935+ this ->lf_upper_bound_size .value ());
936+ }
937+ this ->lf_index .pop_back ();
938+ }
939+
927940 return retval;
928941}
929942
@@ -1075,6 +1088,9 @@ logfile::rebuild_index(std::optional<ui_clock::time_point> deadline)
10751088 if (this ->lf_text_format == text_format_t ::TF_BINARY) {
10761089 this ->lf_index_size = st.st_size ;
10771090 this ->lf_stat = st;
1091+ } else if (this ->lf_upper_bound_size ) {
1092+ this ->lf_index_size = this ->lf_line_buffer .get_file_size ();
1093+ this ->lf_stat = st;
10781094 } else if (this ->lf_line_buffer .is_data_available (this ->lf_index_size ,
10791095 st.st_size ))
10801096 {
@@ -1868,7 +1884,11 @@ logfile::message_byte_length(logfile::const_iterator ll, bool include_continues)
18681884 || (include_continues && next_line->is_continued ())));
18691885
18701886 if (next_line == this ->end ()) {
1871- retval = this ->lf_index_size - ll->get_offset ();
1887+ if (this ->lf_upper_bound_size ) {
1888+ retval = this ->lf_upper_bound_size .value () - ll->get_offset ();
1889+ } else {
1890+ retval = this ->lf_index_size - ll->get_offset ();
1891+ }
18721892 if (retval > line_buffer::MAX_LINE_BUFFER_SIZE) {
18731893 retval = line_buffer::MAX_LINE_BUFFER_SIZE;
18741894 }
0 commit comments