potential fix for #3290
This commit is contained in:
@@ -212,7 +212,6 @@ class Upload < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def move_file
|
def move_file
|
||||||
return if File.exists?(md5_file_path)
|
|
||||||
FileUtils.mv(file_path, md5_file_path)
|
FileUtils.mv(file_path, md5_file_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace :images do
|
|||||||
post_id = ENV["id"]
|
post_id = ENV["id"]
|
||||||
|
|
||||||
if post_id !~ /\d+/
|
if post_id !~ /\d+/
|
||||||
raise "Usage: regen_img.rb POST_ID"
|
raise "Usage: regen id=n"
|
||||||
end
|
end
|
||||||
|
|
||||||
post = Post.find(post_id)
|
post = Post.find(post_id)
|
||||||
@@ -107,9 +107,15 @@ 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
|
||||||
width = 200
|
width = 150
|
||||||
Post.where("image_width > ?", width).find_each do |post|
|
post_id = ENV["id"]
|
||||||
if post.is_image? #&& !File.exists?(post.preview_file_path)
|
|
||||||
|
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}"
|
puts "resizing preview #{post.id}"
|
||||||
Danbooru.resize(post.file_path, post.preview_file_path, width, width, 90)
|
Danbooru.resize(post.file_path, post.preview_file_path, width, width, 90)
|
||||||
end
|
end
|
||||||
@@ -118,8 +124,14 @@ 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_id = ENV["id"]
|
||||||
if post.is_image? && !File.exists?(post.large_file_path)
|
|
||||||
|
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}"
|
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)
|
||||||
post.distribute_files
|
post.distribute_files
|
||||||
|
|||||||
Reference in New Issue
Block a user