Compare commits

..

4 Commits

Author SHA1 Message Date
itsjunetime 2a03294557 Release version 0.4.2 2025-08-18 10:18:26 -05:00
Per Hurtig 7c2c6484a6 Fix macOS shared memory filename length limit (fixes issue #92) (#93)
* Fix macOS shared memory filename length limit

Shorten shared memory object names from "__tdf_kittage_{pid}_page_{rn}_{page_num}"
to "tdf_{pid}_{rn}_{page_num}" and change timestamp from nanoseconds to
milliseconds % 1M to stay under macOS's 31-character limit for shm names.

Fixes "File name too long (os error 63)" error when rendering PDFs on macOS.

On macOS, SHM_NAME_MAX: 30

* Fix macOS shared memory filename length limit

Shorten shared memory object names from "__tdf_kittage_{pid}_page_{rn}_{page_num}"
to "tdf_{pid}_{rn}_{page_num}" and change timestamp from nanoseconds to
milliseconds % 1M to stay under macOS's 31-character limit for shm names.

Fixes "File name too long (os error 63)" error when rendering PDFs on macOS.

SHM_NAME_MAX: 30
2025-08-18 10:15:19 -05:00
itsjunetime e65472e571 Add --version flag 2025-08-15 09:43:52 -05:00
itsjunetime 4fd2237b69 Specify on README to use nightly when building even though it should be detected by rust-toolchain.toml 2025-08-11 21:26:17 -05:00
6 changed files with 28 additions and 13 deletions
+5
View File
@@ -1,5 +1,10 @@
# Unreleased
# v0.4.2
- Add `--version` flag
- Fix shms not working on macos ([#93](https://github.com/itsjunetime/tdf/pull/93))
# v0.4.1
- Add instructions for using new zoom/pan features to help page
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "tdf-viewer"
version = "0.3.0"
version = "0.4.2"
authors = ["June Welker <junewelker@gmail.com>"]
edition = "2024"
description = "A terminal viewer for PDFs"
+1 -1
View File
@@ -25,7 +25,7 @@ If it turns out that you're missing one of these, it will fail to compile and te
1. Get the rust toolchain from [rustup.rs](https://rustup.rs)
2. Clone the repo and `cd` into it
3. Run `cargo build --release`
3. Run `cargo +nightly build --release`
The binary should then be found at `./target/release/tdf`.
+5 -6
View File
@@ -139,14 +139,13 @@ pub async fn run_conversion_loop(
let rn = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_nanos();
.as_millis() % 1_000_000;
let mut img = if shms_work {
kittage::image::Image::shm_from(
dyn_img,
&format!("__tdf_kittage_{pid}_page_{rn}_{page_num}")
)
.map_err(|e| RenderError::Converting(format!("Couldn't write to shm: {e}")))?
kittage::image::Image::shm_from(dyn_img, &format!("tdf_{pid}_{rn}_{page_num}"))
.map_err(|e| {
RenderError::Converting(format!("Couldn't write to shm: {e}"))
})?
} else {
kittage::image::Image::from(dyn_img)
};
+1 -2
View File
@@ -78,8 +78,7 @@ pub async fn run_action<'image, 'data, 'es>(
pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
let img = DynamicImage::new_rgb8(1, 1);
let pid = std::process::id();
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("__tdf_kittage_test_{pid}"))
else {
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("tdf_test_{pid}")) else {
return false;
};
+15 -3
View File
@@ -74,12 +74,24 @@ async fn main() -> Result<(), WrappedErr> {
optional -w,--white-color white: String
/// Custom black color, specified in css format (e.g "000000" or "rgb(0, 0, 0)")
optional -b,--black-color black: String
/// Print the version and exit
optional --version
/// PDF file to read
required file: PathBuf
optional file: PathBuf
};
let path = flags
.file
if flags.version {
println!("{}", env!("CARGO_PKG_VERSION"));
return Ok(());
}
let Some(file) = flags.file else {
return Err(WrappedErr(
"Please specify the file to open, e.g. `tdf ./my_example_pdf.pdf`".into()
));
};
let path = file
.canonicalize()
.map_err(|e| WrappedErr(format!("Cannot canonicalize provided file: {e}").into()))?;