smarter large file regen
This commit is contained in:
@@ -1,8 +0,0 @@
|
|||||||
desc "Download all images from sonohara.donmai.us"
|
|
||||||
task :download_images_from_sonohara => :environment do
|
|
||||||
Post.order("id desc").limit(1000).each do |post|
|
|
||||||
`cd /var/www/danbooru/current/public/data && wget http://sonohara.donmai.us/data/#{post.md5}.#{post.file_ext}`
|
|
||||||
`cd /var/www/danbooru/current/public/data/preview && wget http://sonohara.donmai.us/data/preview/#{post.md5}.jpg`
|
|
||||||
`cd /var/www/danbooru/current/public/data/sample && wget http://sonohara.donmai.us/data/sample/sample-#{post.md5}.jpg`
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -22,7 +22,7 @@ namespace :images do
|
|||||||
desc "Generate thumbnail-sized images of posts"
|
desc "Generate thumbnail-sized images of posts"
|
||||||
task :generate_preview => :environment do
|
task :generate_preview => :environment do
|
||||||
Post.where("image_width > ?", Danbooru.config.small_image_width).find_each do |post|
|
Post.where("image_width > ?", Danbooru.config.small_image_width).find_each do |post|
|
||||||
if post.is_image?
|
if post.is_image? && !File.exists?(post.preview_file_path)
|
||||||
puts "resizing preview #{post.id}"
|
puts "resizing preview #{post.id}"
|
||||||
Danbooru.resize(post.file_path, post.preview_file_path, Danbooru.config.small_image_width, Danbooru.config.small_image_width, 90)
|
Danbooru.resize(post.file_path, post.preview_file_path, Danbooru.config.small_image_width, Danbooru.config.small_image_width, 90)
|
||||||
end
|
end
|
||||||
@@ -32,19 +32,10 @@ namespace :images do
|
|||||||
desc "Generate large-sized images of posts"
|
desc "Generate large-sized images of posts"
|
||||||
task :generate_large => :environment do
|
task :generate_large => :environment do
|
||||||
Post.where("image_width > ?", Danbooru.config.large_image_width).find_each do |post|
|
Post.where("image_width > ?", Danbooru.config.large_image_width).find_each do |post|
|
||||||
if post.is_image?
|
if post.is_image? && !File.exists?(post.large_file_path)
|
||||||
puts "resizing large #{post.id}"
|
puts "resizing large #{post.id}"
|
||||||
Danbooru.resize(post.file_path, post.large_file_path, Danbooru.config.large_image_width, nil, 90)
|
Danbooru.resize(post.file_path, post.large_file_path, Danbooru.config.large_image_width, nil, 90)
|
||||||
end
|
post.distribute_files
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Distribute large posts to other servers"
|
|
||||||
task :distribute_large => :environment do
|
|
||||||
Post.where("image_width > ?", Danbooru.config.large_image_width).find_each do |post|
|
|
||||||
if post.is_image?
|
|
||||||
puts "distributing large #{post.id}"
|
|
||||||
RemoteFileManager.new(post.large_file_path).distribute
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user