File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 11# rc: micro bump
22
3+ - When testing whether the engine needs rerunning, compare the new file to the
4+ entire old file, not just the part that was read by the engine. Should fix
5+ unnecessary reruns in some less-common cases. (#679 , #681 , @pkgw )
6+
7+
8+ # tectonic 0.3.2 (2020-11-14)
9+
310- Slightly alter how some filenames are looked up. Before, if the TeX code
411 requested a file whose name contained an extension, e.g. ` foo.bar ` , if no such
512 file was available in the bundle we gave up immediately. Now we also check for
Original file line number Diff line number Diff line change @@ -469,12 +469,20 @@ impl<'a> ExecutionState<'a> {
469469 let p: * const InputHandle = & * self . input_handles [ i] ;
470470
471471 if p == handle {
472- let ih = self . input_handles . swap_remove ( i) ;
472+ let mut ih = self . input_handles . swap_remove ( i) ;
473+ let mut rv = false ;
474+
475+ if let Err ( e) = ih. scan_remainder ( ) {
476+ tt_warning ! ( self . status, "error closing out input {}" , ih. name( ) . to_string_lossy( ) ; e) ;
477+ rv = true ;
478+ }
479+
473480 let ( name, digest_opt) = ih. into_name_digest ( ) ;
474481 self . events . input_closed ( name, digest_opt) ;
475- return false ;
482+ return rv ;
476483 }
477484 }
485+
478486 // TODO: Handle the error better. This indicates a bug in the engine.
479487 tt_error ! (
480488 self . status,
Original file line number Diff line number Diff line change @@ -141,6 +141,37 @@ impl InputHandle {
141141 self . inner
142142 }
143143
144+ /// Read any remaining data in the file and incorporate them into the
145+ /// digest. This helps the rerun detection logic work correctly in
146+ /// the somewhat-unusual case that a file is read then written, but
147+ /// only part of the file is read, not the entire thing. This seems
148+ /// to happen with biblatex XML state files.
149+ pub fn scan_remainder ( & mut self ) -> Result < ( ) > {
150+ const BUFSIZE : usize = 1024 ;
151+ let mut buf: [ u8 ; BUFSIZE ] = [ 0 ; BUFSIZE ] ;
152+
153+ loop {
154+ let n = match self . inner . read ( & mut buf[ ..] ) {
155+ Ok ( n) => n,
156+
157+ // There are times when the engine tries to open and read
158+ // directories. When closing out such a handle, we'll get this
159+ // error, but we should ignore it.
160+ Err ( ref ioe) if ioe. raw_os_error ( ) == Some ( libc:: EISDIR ) => return Ok ( ( ) ) ,
161+
162+ Err ( e) => return Err ( e. into ( ) ) ,
163+ } ;
164+
165+ if n == 0 {
166+ break ;
167+ }
168+
169+ self . digest . update ( & buf[ ..n] ) ;
170+ }
171+
172+ Ok ( ( ) )
173+ }
174+
144175 /// Consumes the object and returns the SHA256 sum of the content that was
145176 /// read. No digest is returned if there was ever a seek on the input
146177 /// stream, since in that case the results will not be reliable. We also
You can’t perform that action at this time.
0 commit comments