Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

Content type detection locks original file #2016

@daniel-rikowski

Description

@daniel-rikowski

Paperclip::ContentTypeDetector keeps a File object open and thus prevents it from being deleted, moved, etc. until it is closed by the garbage collector.

I was mass-importing images from a zip file and I noticed that I couldn't delete the files after assigning them to Paperclip.

In line 71:

MimeMagic.by_magic(File.open(@filepath)).try(:type)

... the open file is not closed.

Although this problem is unrelated to #1759, #1980 or #1326, it might very well worsen those situations.

IMHO that line should be:

File.open(@filepath) { |f| MimeMagic.by_magic(f).try(:type) }

Shall I make a pull request?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions