fix(linux): always watch CUPS capture cache
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled

This commit is contained in:
Admin 2026-09-24 09:19:46 +00:00
parent 0e619753f1
commit 75e5d36f70
2 changed files with 31 additions and 25 deletions

View File

@ -63,44 +63,49 @@ pub fn start(config: AppConfig, state: SharedState, app: AppHandle) -> Result<Ca
if matches!(config.mode, CaptureMode::SpoolFolder | CaptureMode::Both) { if matches!(config.mode, CaptureMode::SpoolFolder | CaptureMode::Both) {
let spool_dir = PathBuf::from(&config.spool_dir); let spool_dir = PathBuf::from(&config.spool_dir);
fs::create_dir_all(&spool_dir) #[cfg(target_os = "linux")]
.with_context(|| format!("create spool capture directory {}", spool_dir.display()))?; let is_system_cups_spool = spool_dir == PathBuf::from(SYSTEM_CUPS_SPOOL_DIR);
#[cfg(not(target_os = "linux"))]
let is_system_cups_spool = false;
let worker_stop = stop.clone(); if !is_system_cups_spool {
let worker_state = state.clone(); fs::create_dir_all(&spool_dir)
let worker_app = app.clone(); .with_context(|| format!("create spool capture directory {}", spool_dir.display()))?;
let worker_config = config.clone();
handles.push(thread::spawn(move || {
spool_folder_loop(
worker_config,
worker_state,
worker_app,
worker_stop,
None,
"spool-folder",
false,
)
}));
}
#[cfg(target_os = "linux")]
{
let system_spool = PathBuf::from(SYSTEM_CUPS_SPOOL_DIR);
if system_spool != PathBuf::from(&config.spool_dir) {
let worker_stop = stop.clone(); let worker_stop = stop.clone();
let worker_state = state.clone(); let worker_state = state.clone();
let worker_app = app.clone(); let worker_app = app.clone();
let worker_config = config.clone(); let worker_config = config.clone();
handles.push(thread::spawn(move || { handles.push(thread::spawn(move || {
cups_cache_folder_loop( spool_folder_loop(
system_spool,
worker_config, worker_config,
worker_state, worker_state,
worker_app, worker_app,
worker_stop, worker_stop,
None,
"spool-folder",
false,
) )
})); }));
} }
}
#[cfg(target_os = "linux")]
{
let system_spool = PathBuf::from(SYSTEM_CUPS_SPOOL_DIR);
let worker_stop = stop.clone();
let worker_state = state.clone();
let worker_app = app.clone();
let worker_config = config.clone();
handles.push(thread::spawn(move || {
cups_cache_folder_loop(
system_spool,
worker_config,
worker_state,
worker_app,
worker_stop,
)
}));
let sink = TcpListener::bind(TEST_CAPTURE_SINK_ADDR) let sink = TcpListener::bind(TEST_CAPTURE_SINK_ADDR)
.with_context(|| format!("bind test-capture sink {TEST_CAPTURE_SINK_ADDR}"))?; .with_context(|| format!("bind test-capture sink {TEST_CAPTURE_SINK_ADDR}"))?;

View File

@ -37,7 +37,8 @@ job_id = safe(sys.argv[1] if len(sys.argv) > 1 else "job")
title = safe(sys.argv[3] if len(sys.argv) > 3 else "print") title = safe(sys.argv[3] if len(sys.argv) > 3 else "print")
printer = safe(os.environ.get("PRINTER", "printer")) printer = safe(os.environ.get("PRINTER", "printer"))
prefix = "test-" if printer.lower() == "fieldlens-test-capture" else "print-" prefix = "test-" if printer.lower() == "fieldlens-test-capture" else "print-"
name = f"{prefix}{printer}-{job_id}-{title}.pdf" suffix = "" if title.lower().endswith(".pdf") else ".pdf"
name = f"{prefix}{printer}-{job_id}-{title}{suffix}"
final_path = os.path.join(CACHE, name) final_path = os.path.join(CACHE, name)
part_path = final_path + ".part" part_path = final_path + ".part"