From 95595bda06bd03e25f7fc02599e777c79737c324 Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 7 Dec 2013 22:56:41 -0500 Subject: [PATCH] Add fix for #2054 --- script/fixes/022_expunge_missing_images.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 script/fixes/022_expunge_missing_images.rb diff --git a/script/fixes/022_expunge_missing_images.rb b/script/fixes/022_expunge_missing_images.rb new file mode 100644 index 000000000..50b416924 --- /dev/null +++ b/script/fixes/022_expunge_missing_images.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')) + +ActiveRecord::Base.connection.execute("set statement_timeout = 0") + +CurrentUser.user = User.admins.first +CurrentUser.ip_addr = "127.0.0.1" + +Post.where("file_size = 0").find_each do |post| + post.expunge! +end + +Post.where("file_size = 8").find_each do |post| + if File.read(post.file_path) == "danbooru" + post.expunge! + end +end