Skip to content

Commit

Permalink
correctly derive paths for UploadedFileUploader
Browse files Browse the repository at this point in the history
`UploadedFileUploader`'s path generation was extremely fragile. for instance, it
would generate an incorrect path if the configuration option didn't end with
'/'.

to generate a vaild in a system independent way, use `Pathname#/` and then cast
back to a string.
  • Loading branch information
tamsin johnson committed Jun 28, 2022
1 parent 94cd8e0 commit a7e6a62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app/uploaders/hyrax/uploaded_file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ class UploadedFileUploader < CarrierWave::Uploader::Base
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
configured_upload_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
(configured_upload_path / model.class.to_s.underscore / mounted_as} / model.id).to_s
end

def cache_dir
configured_cache_path + "#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
(configured_cache_path / model.class.to_s.underscore / mounted_as / model.id).to_s
end

private

def configured_upload_path
Hyrax.config.upload_path.call
Pathname.new(Hyrax.config.upload_path.call)
end

def configured_cache_path
Hyrax.config.cache_path.call
Pathname.new(Hyrax.config.cache_path.call)
end
end
end
4 changes: 1 addition & 3 deletions chart/hyrax/templates/configmap-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ data:
{{- if .Values.memcached.enabled }}
MEMCACHED_HOST: {{ template "hyrax.memcached.fullname" . }}
{{- end }}
{{- if .Values.derivativesVolume.enabled }}
HYRAX_BRANDING_PATH: "/app/samvera/branding"
HYRAX_DERIVATIVES_PATH: "/app/samvera/derivatives"
HYRAX_CACHE_PATH: "/app/samvera/file_cache"
HYRAX_CACHE_PATH: "/app/samvera/file_cache/"
HYRAX_UPLOAD_PATH: "/app/samvera/uploads"
{{- end }}
RACK_ENV: production
RAILS_ENV: production
{{- if .Values.redis.enabled }}
Expand Down

0 comments on commit a7e6a62

Please sign in to comment.