Use correct loading mechanism for fog-aws

To avoid loading all sorts of fog dependencies, use the fog-aws specific
gem and avoid loading `:fog` providers when not configured.
pull/4424/head
Oliver Günther 9 years ago
parent 13025e811d
commit 593798504b
  1. 2
      Gemfile
  2. 16
      Gemfile.lock
  3. 4
      app/helpers/timelines_helper.rb
  4. 18
      config/initializers/carrierwave.rb
  5. 11
      lib/open_project/configuration/helpers.rb

@ -134,8 +134,8 @@ gem 'unicorn'
gem 'nokogiri', '~> 1.6.7'
gem 'carrierwave', '~> 0.10.0'
gem 'fog-aws'
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'
group :test do
gem 'rack-test', '~> 0.6.2'

@ -1,3 +1,12 @@
GIT
remote: git://github.com/carrierwaveuploader/carrierwave.git
revision: a2c93fe1a9d3a3f60d1662e5ec34fdba7bf2b304
specs:
carrierwave (0.10.0)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
GIT
remote: git://github.com/finnlabs/awesome_nested_set.git
revision: 7bd473e845e2f17f5287e8b7534bd88d4bbbf7d6
@ -167,11 +176,6 @@ GEM
capybara-screenshot (1.0.11)
capybara (>= 1.0, < 3)
launchy
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
climate_control (0.0.3)
@ -582,7 +586,7 @@ DEPENDENCIES
capybara-ng (~> 0.2.2)
capybara-screenshot (~> 1.0.11)
capybara-select2!
carrierwave (~> 0.10.0)
carrierwave!
cocaine
codecov
coderay (~> 1.1.0)

@ -156,10 +156,6 @@ module TimelinesHelper
end
end
# Push timeline data to view as JSON via gon
include Gon::GonHelpers
def push_visible_timelines(visible_timelines, target = gon)
target.timelines = visible_timelines.map { |timeline|
{ id: timeline.id, name: timeline.name, path: project_timeline_path(@project, timeline) }

@ -33,10 +33,9 @@ module CarrierWave
def self.configure_fog!(credentials: OpenProject::Configuration.fog_credentials,
directory: OpenProject::Configuration.fog_directory,
public: false)
require 'fog/aws/storage'
CarrierWave.configure do |config|
config.fog_credentials = credentials
config.fog_provider = 'fog/aws'
config.fog_credentials = { provider: 'AWS' }.merge(credentials)
config.fog_directory = directory
config.fog_public = public
end
@ -47,16 +46,3 @@ end
unless OpenProject::Configuration.fog_credentials.empty?
CarrierWave::Configuration.configure_fog!
end
CarrierWave::Storage::Fog::File.class_eval do
##
# Fixed filename which was returning invalid values when using S3 as the fog storage
# due to crappy regex magic.
def filename(options = {})
if file_url = url(options)
uri = URI.parse(file_url)
path = URI.decode uri.path
Pathname(path).basename.to_s
end
end
end

@ -74,10 +74,17 @@ module OpenProject
end
def available_file_uploaders
{
fog: ::FogFileUploader,
uploaders = {
file: ::LocalFileUploader
}
# Do not load Fog uploader unless configured,
# it will fail with missing configuration
unless OpenProject::Configuration.fog_credentials.empty?
uploaders[:fog] = '::FogFileUploader'.constantize
end
uploaders
end
private

Loading…
Cancel
Save