Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically increase the open files limit if needed #14

Merged
merged 4 commits into from
Jul 16, 2022
Merged

Dynamically increase the open files limit if needed #14

merged 4 commits into from
Jul 16, 2022

Conversation

tagatac
Copy link
Owner

@tagatac tagatac commented Jul 16, 2022

wkhtmltopdf appears to keep all embedded image files open until the PDF is written: wkhtmltopdf/wkhtmltopdf#3081
As a consequence, we need to allow for large numbers of open files in the case that there are many embedded images.

Also, long URLs without dashes are not wrapped by default, decreasing the font size for the entire document. word-wrap: break-word fixes this.

@codecov
Copy link

codecov bot commented Jul 16, 2022

Codecov Report

Merging #14 (c099bf4) into main (8a3034c) will decrease coverage by 0.59%.
The diff coverage is 83.60%.

@@            Coverage Diff             @@
##             main      #14      +/-   ##
==========================================
- Coverage   92.17%   91.58%   -0.60%     
==========================================
  Files           4        4              
  Lines         537      582      +45     
==========================================
+ Hits          495      533      +38     
- Misses         37       42       +5     
- Partials        5        7       +2     
Impacted Files Coverage Δ
opsys/opsys.go 92.74% <77.77%> (-4.23%) ⬇️
opsys/outfile.go 89.02% <81.81%> (+1.02%) ⬆️
main.go 85.49% <91.30%> (+0.49%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a3034c...c099bf4. Read the comment docs.

@tagatac tagatac merged commit 99bb395 into main Jul 16, 2022
@tagatac tagatac deleted the ulimit branch July 16, 2022 07:20
tagatac added a commit that referenced this pull request Sep 10, 2024
**What is changing**: Check the OS-level open file limit (and adjust it
if necessary) prior to writing PDF files.

**Why this change is being made**: There is the potential for
wkhtmltopdf to need many open files (see
wkhtmltopdf/wkhtmltopdf#3081). This was fixed
in #14, where it depended on the order of events:
1. Stage the PDF file, getting the number of images
2. Check and adjust the open file limit
3. Flush the PDF file to disk

Number 3 was achieved via the call `defer outFile.Close()`:
https://github.com/tagatac/bagoup/blob/86f9b32870d2127f3fd3e196cecfc24265cf8d87/write.go#L29

However, #29 removed `Close()` from the `OutFile` interface, collapsing
`Stage()` and `Flush()` into a single function `Flush()` run prior to
checking and adjusting the open file limit.

**Related issue(s)**: Fixes #63 

**Follow-up changes needed**: None AFAIK

**Is the change completely covered by unit tests? If not, why not?**:
Yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant