Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage manager: remove
hierarchical
option.
Remove the `hierarchical` file storage option. This means that image files are always stored in MD5-based subdirectories, like this: https://danbooru.donmai.us/data/original/f3/a7/f3a70a89c350b5ed4db22dbb25b934bb.jpg https://danbooru.donmai.us/data/sample/f3/a7/sample-f3a70a89c350b5ed4db22dbb25b934bb.jpg https://danbooru.donmai.us/data/preview/f3/a7/f3a70a89c350b5ed4db22dbb25b934bb.jpg instead of in a single flat directory, like this: https://danbooru.donmai.us/data/original/f3a70a89c350b5ed4db22dbb25b934bb.jpg This option is removed because storing files in a single directory is a bad idea for large installations, and migrating from a single directory to subdirectories later is a pain. Downstream boorus who still have files in the old layout can migrate by running this script: `./script/fixes/077_symlink_subdirectories.rb` This will create symlinks that redirect the 00-ff subdirectories back to the current directory, so that you can still store files in a single directory, but use URLs containing subdirectories. You should also make sure to remove the `hierarchical` option from `storage_manager` in `config/danbooru_local_config.rb` if you set it there.
- Loading branch information
Showing
7 changed files
with
57 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require_relative "../../config/environment" | ||
|
||
def create_symlinks(dir) | ||
FileUtils.mkdir_p(dir) | ||
|
||
(0..255).each do |i| | ||
subdir = "#{dir}/#{"%.2x" % i}" | ||
|
||
if File.exist?(subdir) | ||
puts "skipping #{subdir}" | ||
else | ||
puts "ln -sf . #{subdir}" | ||
FileUtils.ln_sf(".", subdir) | ||
end | ||
end | ||
end | ||
|
||
root = Rails.root.join("public/data") | ||
|
||
create_symlinks(root) | ||
create_symlinks("#{root}/sample") | ||
create_symlinks("#{root}/preview") | ||
create_symlinks("#{root}/crop") | ||
|
||
FileUtils.ln_sf(".", "#{root}/original") unless File.exist?("#{root}/original") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters