-
Notifications
You must be signed in to change notification settings - Fork 900
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
Stub mini-mime in for mime-types #14525
Conversation
For the record, have not ran anything to confirm that this works as an interface, only that the application loads when this is in place. Further tests will need to be done before we even consider merging this. |
end | ||
|
||
def self.type_for filename | ||
Array.wrap MiniMime.lookup_by_filename(filename) |
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.
I think you need a .collect(&:content_type)
here?
Array.wrap(MiniMime.lookup_by_filename(filename).content_type)
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.
@Fryguy Well, I was going off of this change:
So I don't think so, but maybe I read that diff wrong (it was Monday morning at the time of writing this code...)
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.
Oh... I think I see the error in my ways now...
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.
I think I was right the first time... see #14525 (comment)
40f284d
to
09dffb6
Compare
Once this gets nailed down, this might be a good addition to the mini_mime gem. This way they have a workaround to intercepting mime/types in places where rest-client or mail can't be upgraded. |
I agree, though I am not sure how we could do that from within the |
@Fryguy I think the way that is called, that is different, but I did see that one, which is why I was confused for a bit. But looking at this: https://github.com/ManageIQ/manageiq/blob/master/app/models/filesystem.rb#L111-L118 Looks like I think returning a |
Booted myself from the reviewers list. Mime types are just not anything I feel I can give an up or down vote. |
This pull request is not mergeable. Please rebase and repush. |
09dffb6
to
f2fd8c5
Compare
@NickLaMuro Do you have any numbers for the memory/time savings? I thought they were in this thread, but i can't find them. |
s.summary = "Stub mime-types repo that redirects to mini-mime" | ||
|
||
s.add_dependency 'mini_mime', '>= 0.1.1' | ||
end |
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.
I'm wondering if we can just make this a released gem somehow, but I can't think of how you would make the Gemfile work. 🤔
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.
Yeah, that was my thing too. We can't make this quack as a dependency that is resolvable using rubygems, and so the best we could do is move this into a git repo... but that even seems overkill.
Not completely opposed to the idea, though, hate adding another git gem to the repo... Either way, I would probably put some tests around it if we wanted to do that.
@Fryguy Yeah, I feel like we might have talked about this in chat or something with the people involved, but it is around a 10MiB savings. Regardless, will do a quick test before and after and add it to the top. |
@Fryguy well, I have been testing for probably the past 20 min, and the results are varied enough where I don't think putting them here in full will help. But the short version is what I have here is basically a 0.0MiB for the |
f2fd8c5
to
3879297
Compare
@NickLaMuro Can you verify that with the change, that the UI classic repo still passes? I am concerned because UI classic still references capybara which, in turn, still uses the mime-types gem and I'm concerned that it will try to load the gem anyway, clobbering your changes. |
Uses a stub for the two mime-types methods used by rest-client and mail (the only dependencies of mime-types) and forwards them on to mini-mime. Should reduce the memory footprint from that gem... hopefully...
Said in a PM to @Fryguy, but I used this branch to run the test suite for |
3879297
to
8cfab3b
Compare
Checked commit NickLaMuro@8cfab3b with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 mime-types-redirector/lib/mime-types.rb
|
Looks good to me...merging, and then let's see how it plays out. |
@NickLaMuro I've opened discourse/mini_mime#6 to see if we can get this into mini_mime in some form, if they are willing to accept it. |
@Fryguy Thanks! I think having a more official solution is probably for the best. |
Note this also seems to break running
But making a symlink to that dir fixes that :) |
@himdel Do you have a link to what test was failing with this? I might see if there is another bug with bundler that I need to look into with this. |
As just a minor FYI, this only fixes the problem where |
@NickLaMuro It was not a specific test failing, it was not being able to run any specs via EDIT: And @martinpovolny just hit the |
Relative pathing can have problems if the pwd is not the manageiq directory. This ensures the correct path. Related: - ManageIQ#14525 - ManageIQ/manageiq-ui-classic#1606 - ManageIQ/manageiq-content#136
Uses a stub for the two
mime-types
methods used byrest-client
andmail
(the only dependencies ofmime-types
) and forwards them on tomini-mime
. Should reduce the memory footprint from that gem... hopefully...Before
After
For those stopping in (👋) , the links to the
rest-client
PR will provide some context to why this PR exists.Links
rest-client
: PERF: Eliminate dependency on mime-types gem rest-client/rest-client#557