From 4095d14f2a8e45242df62d803129106ec53497ad Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 27 Oct 2021 19:44:42 -0500 Subject: [PATCH] media assets: fix tagged filenames option. Fix the `enable_seo_post_urls` config option not being respected. This option controls whether filenames in image URLs contain the tags. This option requires URLs rewrites in Nginx to work so it's disabled by default. --- app/logical/storage_manager.rb | 6 ++---- app/models/media_asset.rb | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/logical/storage_manager.rb b/app/logical/storage_manager.rb index b12d1f674..56f5fc75a 100644 --- a/app/logical/storage_manager.rb +++ b/app/logical/storage_manager.rb @@ -11,16 +11,14 @@ class StorageManager class Error < StandardError; end - attr_reader :base_url, :base_dir, :tagged_filenames + attr_reader :base_url, :base_dir # Initialize a storage manager object. # @param base_url [String] the base URL where images are stored (ex: "https://cdn.donmai.us/") # @param base_dir [String] the base directory where images are stored (ex: "/var/www/danbooru/public/images") - # @param tagged_filenames [Boolean] whether image URLs can include tags - def initialize(base_url: nil, base_dir: nil, tagged_filenames: Danbooru.config.enable_seo_post_urls) + def initialize(base_url: nil, base_dir: nil) @base_url = base_url.to_s.chomp("/") @base_dir = base_dir.to_s - @tagged_filenames = tagged_filenames end # Store the given file at the given path. If a file already exists at that diff --git a/app/models/media_asset.rb b/app/models/media_asset.rb index fb2c70675..4b88b720c 100644 --- a/app/models/media_asset.rb +++ b/app/models/media_asset.rb @@ -67,6 +67,7 @@ class MediaAsset < ApplicationRecord "/images/download-preview.png" else slug = "__#{slug}__" if slug.present? + slug = nil if !Danbooru.config.enable_seo_post_urls "/#{variant}/#{md5[0..1]}/#{md5[2..3]}/#{slug}#{file_name}" end end