From c2e0eeb0892308f6fa275d5811b08e84b79578b1 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Thu, 10 Mar 2016 00:47:18 -0300 Subject: [PATCH] Separate relative base_url and upload_path This makes easier to reason about paths --- lib/file_store/local_store.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/file_store/local_store.rb b/lib/file_store/local_store.rb index 0f559f89f05..a4068e57d12 100644 --- a/lib/file_store/local_store.rb +++ b/lib/file_store/local_store.rb @@ -34,8 +34,12 @@ module FileStore "#{Discourse.asset_host}#{relative_base_url}" end + def upload_path + "/uploads/#{RailsMultisite::ConnectionManagement.current_db}" + end + def relative_base_url - "#{Discourse.base_uri}/uploads/#{RailsMultisite::ConnectionManagement.current_db}" + "#{Discourse.base_uri}#{upload_path}" end def external? @@ -57,7 +61,7 @@ module FileStore end def get_path_for(type, upload_id, sha, extension) - "#{relative_base_url}/#{super(type, upload_id, sha, extension)}" + "#{upload_path}/#{super(type, upload_id, sha, extension)}" end def copy_file(file, path)