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

Skipping work in a processor #64

Open
ClearlyClaire opened this issue Sep 10, 2021 · 0 comments
Open

Skipping work in a processor #64

ClearlyClaire opened this issue Sep 10, 2021 · 0 comments

Comments

@ClearlyClaire
Copy link

ClearlyClaire commented Sep 10, 2021

Is your feature request related to a problem? Please describe.

We've been using Paperclip for a while in Mastodon, and we're chaining processors. Sometimes, a processor can decide it doesn't need to perform any change to the file. In this case, we just re-open the file to pass it to the next processor:

class LazyThumbnail < Paperclip::Thumbnail
  def make
    return File.open(@file.path) unless needs_convert?

    # … actual code
  end
end

This worked up until Paperclip 6.1, which caused the files to be closed after each processor in thoughtbot@90f9121, resulting in Errno::ENOENT errors.

This behavior remains unchanged in kt-paperclip so I was wondering how to best implement this “lazy” processor.

Looking at https://github.com/kreeti/kt-paperclip/blob/master/lib/paperclip/attachment.rb#L523-L530, there seem to be no clear way to handle that case.

Describe the solution you'd like

kt-paperclip should maybe unlink the original tempfile only once it has been fully processed. Pushing original into intermediate_files instead of immediately unlinking it should do the trick.

Describe alternatives you've considered

Our LazyThumbnail could create a copy of the file, but it seems wasteful.

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

No branches or pull requests

1 participant