From 0314dc9751a0eeeb08846872d00ae99deb7c8bff Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Wed, 15 Aug 2018 16:08:10 -0700 Subject: [PATCH] more consistent behavior of CurrentUser.root_url --- app/controllers/application_controller.rb | 2 +- app/logical/current_user.rb | 2 +- app/logical/storage_manager.rb | 2 +- config/danbooru_default_config.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 649546155..fa9f6af55 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -176,7 +176,7 @@ class ApplicationController < ActionController::Base def reset_current_user CurrentUser.user = nil CurrentUser.ip_addr = nil - CurrentUser.root_url = root_url + CurrentUser.root_url = root_url.chomp("/") end def set_started_at_session diff --git a/app/logical/current_user.rb b/app/logical/current_user.rb index 3f9366c17..e30e44501 100644 --- a/app/logical/current_user.rb +++ b/app/logical/current_user.rb @@ -59,7 +59,7 @@ class CurrentUser end def self.root_url - Thread.current[:current_root_url] || "https://#{Danbooru.config.hostname}/" + Thread.current[:current_root_url] || "https://#{Danbooru.config.hostname}" end def self.root_url=(root_url) diff --git a/app/logical/storage_manager.rb b/app/logical/storage_manager.rb index 1520b6824..2937d6b3c 100644 --- a/app/logical/storage_manager.rb +++ b/app/logical/storage_manager.rb @@ -14,7 +14,7 @@ class StorageManager end def default_base_url - CurrentUser.root_url + "data" + "#{CurrentUser.root_url}/data" end # Store the given file at the given path. If a file already exists at that diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index e1110ca6f..49205cd4f 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -254,7 +254,7 @@ module Danbooru # base_url - where to serve files from (default: http://#{hostname}/data) # hierarchical: false - store files in a single directory # hierarchical: true - store files in a hierarchical directory structure, based on the MD5 hash - StorageManager::Local.new(base_url: CurrentUser.root_url + "data", base_dir: "#{Rails.root}/public/data", hierarchical: false) + StorageManager::Local.new(base_url: "#{CurrentUser.root_url}/data", base_dir: "#{Rails.root}/public/data", hierarchical: false) # Store files on one or more remote host(s). Configure SSH settings in # ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start)