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

fix: check if file exists before deleting #1074

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LuanGB
Copy link

@LuanGB LuanGB commented Sep 5, 2023

fixes #1073

@unixmonkey
Copy link
Collaborator

FYI, this issue also may exist here: https://github.com/mileszs/wicked_pdf/blob/master/lib/wicked_pdf.rb#L46-L50 where the files are closed without checking they exist first.

I'm curious how this is a new problem after the upgrade though... It seems that if any other process clearing tempfiles (a deploy maybe?) could cause this to happen in both old and new versions.

It might also be nice to delete or preserve the header & footer tempfiles with that same :delete_temporary_files option and call close or close! based on it.

@LuanGB
Copy link
Author

LuanGB commented Sep 5, 2023

I'm suspecting that this may be related to this PR: #1039
Cannot put my finger on what exactly is causing it, however

@unixmonkey
Copy link
Collaborator

BTW, although it is very tiny, there could be a race-condition where the file exists while checking if the file exists and deleting it. Maybe it'd be better if closing a tempfile were rescue-able than checking for existence. Should speed things up too.

@LuanGB
Copy link
Author

LuanGB commented Sep 5, 2023

That's a good idea. I'll put something together soon.

@unixmonkey
Copy link
Collaborator

Ping.

@alex-kovshovik
Copy link

I ran into the same issue, probably will have to use the forked version until this fix is released.

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.

No such file or directory @ apply2files
3 participants