Fix mime checking when unix util "file" version <5. #1537
Fix mime checking when unix util "file" version <5. #1537
Conversation
This looks good. Would you mind adding these two test cases?
Thank you so much for your patch. |
I like this idea, but maybe we should also look into memoizing the version check? Also, file 5 has been out since 2/4/2009 - what supported distros have file version 4 ? |
@sikachu I'd forgotten about this, but the last comment just brought it back to my attention. Could you clarify what you want as a test case with your first request? As long as the correct flag/option is used, the output from the file command is identical, so I'm not exactly sure what the test case should test given that we can't easily test against both version of the file command. @djcp I don't mind adding a simple cache so that we don't have to recheck every time, though technically I suppose that that could cause some odd issues in the unlikely chance that someone upgraded the file command while your app was running. As to the distros, I know the old version is still in CentOS 5.7. While I realize that's ancient, it's it's also true that quite a few shops/companies have to work with the fact that many places are incredibly slow to update distro versions. |
+1 |
@sikachu I'm still waiting to hear back on what kind of test you'd like added here. I'm willing to add the test, but I'd like a bit of direction since the only test I can imagine would be an integration test that actually runs on different system with differing versions of the file command. |
@rubyisbeautiful I am running RHEL 5.11 which is claiming to have file 4.17 - but both -i and --mime work fine. $ cat /etc/redhat-release |
Hi everybody! Is this still an issue? If so, can you please rebase your PR and make sure everything is passing? Thanks! |
@maclover7 It's no longer an issue for me/us, @cnk's findings are true for stock 5.10/5.11. I assume it was something weird with our environment on that project (wouldn't be the first time). Thanks!! |
@maclover7 While I'm not personally affected by this anymore as we've moved to AWS (and a newer OS in the process), the code still has the same problem. |
This is potentially relevant in #1506, but it doesn't really affect the current choices, rather, it merely ensures that the current code works even on older versions of the
file
command on unix/linux.For versions prior to 5, the
-i
option provides the mime type. That option doesn't exist in version 5 and has been replaced with the--mime
that Paperclip was using by default.