From 2b429c928cf6284f388d702718d6bb21e648541f Mon Sep 17 00:00:00 2001 From: albert Date: Thu, 21 Feb 2013 18:25:21 -0500 Subject: [PATCH] smarter large file regen --- lib/tasks/download_images_from_sonohara.rake | 8 -------- lib/tasks/images.rake | 15 +++------------ 2 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 lib/tasks/download_images_from_sonohara.rake diff --git a/lib/tasks/download_images_from_sonohara.rake b/lib/tasks/download_images_from_sonohara.rake deleted file mode 100644 index 32ede87be..000000000 --- a/lib/tasks/download_images_from_sonohara.rake +++ /dev/null @@ -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 diff --git a/lib/tasks/images.rake b/lib/tasks/images.rake index 03ea1d325..8c70f2f16 100644 --- a/lib/tasks/images.rake +++ b/lib/tasks/images.rake @@ -22,7 +22,7 @@ namespace :images do desc "Generate thumbnail-sized images of posts" task :generate_preview => :environment do 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}" Danbooru.resize(post.file_path, post.preview_file_path, Danbooru.config.small_image_width, Danbooru.config.small_image_width, 90) end @@ -32,19 +32,10 @@ namespace :images do desc "Generate large-sized images of posts" task :generate_large => :environment do 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}" Danbooru.resize(post.file_path, post.large_file_path, Danbooru.config.large_image_width, nil, 90) - end - 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 + post.distribute_files end end end