-
Notifications
You must be signed in to change notification settings - Fork 72
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
Update pdf_generator.ex #8
Conversation
Add html_file to the returned value. Use case: someone wants to remove the html temporary file
@edipox Thanks for your PR! Usually one shouldn't care about temporary files (your OS should do) so explicit deleting isn't usually necessary. On the other hand there's no real reason not to be able to delete that file but I'd rather see an option to the call than changing it's return value signature from a 2-element tuple to a 3-element tuple as this would surely break someone's code (at least mine) when pattern-matching the result of
So I'd rather suggest an option Tell what you think |
Yeah, you are totally right. I didn't think about code breaking issues. This is my situation: pdf generation per concurrent request. So I can't let the OS delete the files, because it could be too late and the disk space could end. And I can't delete all the .html files after each request because another request could be reading a file while I am deleting it. |
@gutschilla I did what you suggested. Could you take a look? |
@@ -133,6 +135,11 @@ defmodule PdfGenerator do | |||
executable, arguments, [in: "", out: :string, err: :string] | |||
) | |||
|
|||
case Keyword.get(options, :delete_temporary) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be rewritten as
if Keyword.get(options, :delete_temporary) == :html do
File.rm html_file
end
In my opinion, no need for a nil -> nil
case
Thanks a lot for your patch and thanks as well for removing all these spaces at line endings. Would you please take a look at my small-ish line comment? |
@gutschilla Done! |
Beautiful! Thanks a lot for your contribution! |
Add html_file to the returned value.
Use case: someone wants to remove the html temporary file