potential fix for #3290

This commit is contained in:
r888888888 2017-09-13 12:55:04 -07:00
parent c2b49bf2b7
commit 75f87bcc8e
2 changed files with 18 additions and 7 deletions

View File

@ -212,7 +212,6 @@ class Upload < ApplicationRecord
end
def move_file
return if File.exists?(md5_file_path)
FileUtils.mv(file_path, md5_file_path)
end

View File

@ -92,7 +92,7 @@ namespace :images do
post_id = ENV["id"]
if post_id !~ /\d+/
raise "Usage: regen_img.rb POST_ID"
raise "Usage: regen id=n"
end
post = Post.find(post_id)
@ -107,9 +107,15 @@ namespace :images do
desc "Generate thumbnail-sized images of posts"
task :generate_preview => :environment do
width = 200
Post.where("image_width > ?", width).find_each do |post|
if post.is_image? #&& !File.exists?(post.preview_file_path)
width = 150
post_id = ENV["id"]
if post_id !~ /\d+/
raise "Usage: generate_preview id=n"
end
Post.where(id: post_id).find_each do |post|
if post.is_image?
puts "resizing preview #{post.id}"
Danbooru.resize(post.file_path, post.preview_file_path, width, width, 90)
end
@ -118,8 +124,14 @@ 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? && !File.exists?(post.large_file_path)
post_id = ENV["id"]
if post_id !~ /\d+/
raise "Usage: generate_large id=n"
end
Post.where(id: post_id).find_each do |post|
if post.is_image? && post.has_large?
puts "resizing large #{post.id}"
Danbooru.resize(post.file_path, post.large_file_path, Danbooru.config.large_image_width, nil, 90)
post.distribute_files