Promote verified native PDF and box capacity support
This commit is contained in:
1 parent
3706afa483
commit
72ed779749
31 files changed
+1042
-78
No files matched your search
+37
-1
@@ -10,6 +10,7 @@ use sha2::{Digest, Sha256};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
ffi::OsStr,
|
||||
fs::{self, File, OpenOptions},
|
||||
io::{self, BufRead, BufReader, Seek, Write},
|
||||
path::{Path, PathBuf},
|
||||
@@ -21,7 +22,42 @@ use texrra_tex_core::execution::{
|
||||
use texrra_tex_core::resources::{FileWorld, LoadedResource, ResourceKind, ResourceVersion};
|
||||
|
||||
pub fn job_time() -> Result<JobTime, String> {
|
||||
pdf_clock(chrono::Local::now().fixed_offset())
|
||||
let local = chrono::Local::now().fixed_offset();
|
||||
let source_date = std::env::var_os("SOURCE_DATE_EPOCH");
|
||||
let force_utc = std::env::var_os("FORCE_SOURCE_DATE").is_some_and(|value| value == "1");
|
||||
let pdf_date = match source_date {
|
||||
Some(value) => source_date_epoch(&value)?,
|
||||
None => local,
|
||||
};
|
||||
let registers = if force_utc {
|
||||
pdf_date.to_utc().fixed_offset()
|
||||
} else {
|
||||
local
|
||||
};
|
||||
Ok(pdf_clock(registers)?.with_pdf_date(pdf_clock(pdf_date)?))
|
||||
}
|
||||
|
||||
fn source_date_epoch(value: &OsStr) -> Result<DateTime<FixedOffset>, String> {
|
||||
let invalid = || format!("invalid value for SOURCE_DATE_EPOCH: {value:?}");
|
||||
let value = value.to_str().ok_or_else(invalid)?;
|
||||
if value.is_empty() {
|
||||
return Ok(DateTime::UNIX_EPOCH.fixed_offset());
|
||||
}
|
||||
let number = value.trim_start_matches(|c: char| c.is_ascii_whitespace());
|
||||
let digits = number.trim_start_matches(['-', '+']);
|
||||
let sign_len = number.len() - digits.len();
|
||||
if sign_len > 1 || !digits.bytes().all(|b| b.is_ascii_digit()) {
|
||||
return Err(invalid());
|
||||
}
|
||||
let magnitude = digits.parse::<u64>().map_err(|_| invalid())?;
|
||||
let seconds = if number.starts_with('-') {
|
||||
magnitude.wrapping_neg()
|
||||
} else {
|
||||
magnitude
|
||||
};
|
||||
DateTime::from_timestamp(seconds as i64, 0)
|
||||
.map(|date| date.fixed_offset())
|
||||
.ok_or_else(invalid)
|
||||
}
|
||||
|
||||
fn pdf_clock(time: DateTime<FixedOffset>) -> Result<JobTime, String> {
|
||||
|
||||
Reference in new issue
Block a user