From e3a9614930827e8ac3bcf3529a7d567fdbc62cd6 Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 23 Aug 2011 16:15:29 -0400 Subject: [PATCH] fixes to whenever scripts --- app/models/post.rb | 23 ++++++++++++++++++++--- config/danbooru_default_config.rb | 5 +++++ config/schedule.rb | 6 +++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index d9e82f357..fb52bed3b 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -65,7 +65,8 @@ class Post < ActiveRecord::Base FileUtils.rm_f(file_path) FileUtils.rm_f(medium_file_path) FileUtils.rm_f(large_file_path) - FileUtils.rm_f(preview_file_path) + FileUtils.rm_f(ssd_preview_file_path) if Danbooru.config.ssd_path + FileUtils.rm_f(real_preview_file_path) end def file_path_prefix @@ -91,9 +92,21 @@ class Post < ActiveRecord::Base file_path end end + + def real_preview_file_path + "#{Rails.root}/public/data/preview/#{file_path_prefix}#{md5}.jpg" + end + + def ssd_preview_file_path + "#{Danbooru.config.ssd_path}/public/data/preview/#{file_path_preview}#{md5}.jpg" + end def preview_file_path - "#{Rails.root}/public/data/preview/#{file_path_prefix}#{md5}.jpg" + if Danbooru.config.ssd_path + ssd_preview_file_path + else + real_preview_file_path + end end def file_url @@ -117,7 +130,11 @@ class Post < ActiveRecord::Base end def preview_file_url - "/data/preview/#{file_path_prefix}#{md5}.jpg" + if Danbooru.config.ssd_path + "/ssd/data/preview/#{file_path_prefix}#{md5}.jpg" + else + "/data/preview/#{file_path_prefix}#{md5}.jpg" + end end def file_url_for(user) diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index f4698b164..3e659bc9c 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -72,6 +72,11 @@ module Danbooru 300 end + # If a solid state drive is availble, cache the thumbnails on the SSD to reduce disk seek times. + def ssd_path + nil + end + # List of memcached servers def memcached_servers %w(localhost:11211) diff --git a/config/schedule.rb b/config/schedule.rb index 411d6af5c..6bf986368 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,11 +1,11 @@ set :output, "/var/log/whenever.log" every 1.hour do - TagSubscription.process_all + runner "TagSubscription.process_all" end -if fetch(:whenever_environment) == "production" +if environment == "production" every 1.hour do - AmazonBackup.execute + runner "AmazonBackup.execute" end end