From 929b2fa8965b1452b194346bfd5d195158514b13 Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Wed, 28 Mar 2018 17:19:21 -0700 Subject: [PATCH] move default base url to method to deal with deployment issues --- app/logical/storage_manager.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/logical/storage_manager.rb b/app/logical/storage_manager.rb index 1ce833f88..8c1fbd0e4 100644 --- a/app/logical/storage_manager.rb +++ b/app/logical/storage_manager.rb @@ -1,12 +1,11 @@ class StorageManager class Error < StandardError; end - DEFAULT_BASE_URL = Rails.application.routes.url_helpers.root_url + "data" DEFAULT_BASE_DIR = "#{Rails.root}/public/data" attr_reader :base_url, :base_dir, :hierarchical, :tagged_filenames, :large_image_prefix - def initialize(base_url: DEFAULT_BASE_URL, base_dir: DEFAULT_BASE_DIR, hierarchical: false, tagged_filenames: Danbooru.config.enable_seo_post_urls, large_image_prefix: Danbooru.config.large_image_prefix) + def initialize(base_url: default_base_url, base_dir: DEFAULT_BASE_DIR, hierarchical: false, tagged_filenames: Danbooru.config.enable_seo_post_urls, large_image_prefix: Danbooru.config.large_image_prefix) @base_url = base_url.chomp("/") @base_dir = base_dir @hierarchical = hierarchical @@ -14,6 +13,10 @@ class StorageManager @large_image_prefix = large_image_prefix end + def default_base_url + Rails.application.routes.url_helpers.root_url + "data" + end + # Store the given file at the given path. If a file already exists at that # location it should be overwritten atomically. Either the file is fully # written, or an error is raised and the original file is left unchanged. The