Hash page instead of frame for watch command (#6810)
This commit is contained in:
parent
c7938e93dc
commit
f278e43e0f
|
|
@ -15,7 +15,7 @@ use typst::diag::{
|
||||||
At, Severity, SourceDiagnostic, SourceResult, StrResult, Warned, bail,
|
At, Severity, SourceDiagnostic, SourceResult, StrResult, Warned, bail,
|
||||||
};
|
};
|
||||||
use typst::foundations::{Datetime, Smart};
|
use typst::foundations::{Datetime, Smart};
|
||||||
use typst::layout::{Frame, Page, PageRanges, PagedDocument};
|
use typst::layout::{Page, PageRanges, PagedDocument};
|
||||||
use typst::syntax::{FileId, Lines, Span};
|
use typst::syntax::{FileId, Lines, Span};
|
||||||
use typst_html::HtmlDocument;
|
use typst_html::HtmlDocument;
|
||||||
use typst_pdf::{PdfOptions, PdfStandards, Timestamp};
|
use typst_pdf::{PdfOptions, PdfStandards, Timestamp};
|
||||||
|
|
@ -380,7 +380,7 @@ fn export_image(
|
||||||
// If the frame is in the cache, skip it.
|
// If the frame is in the cache, skip it.
|
||||||
// If the file does not exist, always create it.
|
// If the file does not exist, always create it.
|
||||||
if config.watching
|
if config.watching
|
||||||
&& config.export_cache.is_cached(*i, &page.frame)
|
&& config.export_cache.is_cached(*i, page)
|
||||||
&& path.exists()
|
&& path.exists()
|
||||||
{
|
{
|
||||||
return Ok(Output::Path(path.to_path_buf()));
|
return Ok(Output::Path(path.to_path_buf()));
|
||||||
|
|
@ -483,8 +483,8 @@ impl ExportCache {
|
||||||
|
|
||||||
/// Returns true if the entry is cached and appends the new hash to the
|
/// Returns true if the entry is cached and appends the new hash to the
|
||||||
/// cache (for the next compilation).
|
/// cache (for the next compilation).
|
||||||
pub fn is_cached(&self, i: usize, frame: &Frame) -> bool {
|
pub fn is_cached(&self, i: usize, page: &Page) -> bool {
|
||||||
let hash = typst::utils::hash128(frame);
|
let hash = typst::utils::hash128(page);
|
||||||
|
|
||||||
let mut cache = self.cache.upgradable_read();
|
let mut cache = self.cache.upgradable_read();
|
||||||
if i >= cache.len() {
|
if i >= cache.len() {
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ pub struct PagedDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A finished page.
|
/// A finished page.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Hash)]
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
/// The frame that defines the page.
|
/// The frame that defines the page.
|
||||||
pub frame: Frame,
|
pub frame: Frame,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue