michaelrsweet / pappl

PAPPL - Printer Application Framework
https://www.msweet.org/pappl
Apache License 2.0
309 stars 49 forks source link

When printing, job file goes into TMPDIR not into spool directory and does not get removed afterwards #151

Closed tillkamppeter closed 3 years ago

tillkamppeter commented 3 years ago

When I create the system with papplCreateSystem() I specify a spool directory, but when I print, the print job file (the PDF file I have sent, not the PostScript file which the Printer Application generates and sends to the printer, names are hex numbers like 21c4596028da14), is put into the temporary directory (TMPDIR) and not deleted after the job is done. With the time many job files accumulate in the temporary directory.

This also happens if I do not specify a spool directory and PAPPLs default name (${TMPDIR}/pappl${PID}.d) is used.

michaelrsweet commented 3 years ago

@tillkamppeter Weird, the code in question uses the system directory, which is copied in papplSystemCreate. I assume you are using a system callback in your call to papplMainLoop?

The job files that PAPPL will create always have an extension (even if it is just ".prn") and use the job-id, job-name, and printer-id values - hex values tell me those are files created with cupsTempFd which only happen if you are uploading files via HTML forms (and then they should be removed as soon as the request processing is done...) or submitting stdin from the command-line (which should be cleaning up after itself as well...)

tillkamppeter commented 3 years ago

That the hex names come from cupsTempFd() is a good hint. So it seems for me that these are files left over by the PDF-to-PostScript filtering which is done by a filter function derived from a CUPS filter. As formerly CUPS filters were running as external executable, temp files got cleaned up when the filter was done due to the fact that the process ended. Seems that I have to unlink the temp files at the end of the filter functions.

tillkamppeter commented 3 years ago

Fixed temporary file leaks in cups-filters and this solved the problem. Thank you very much for the hint.