diff --git a/app/logical/downloads/rewrite_strategies/pixiv.rb b/app/logical/downloads/rewrite_strategies/pixiv.rb index 7b9e35b60..358add316 100644 --- a/app/logical/downloads/rewrite_strategies/pixiv.rb +++ b/app/logical/downloads/rewrite_strategies/pixiv.rb @@ -17,7 +17,7 @@ module Downloads end # http://i2.pixiv.net/img-zip-ugoira/img/2014/08/05/06/01/10/44524589_ugoira1920x1080.zip - if url =~ %r!\Ahttps?://i[12]\.pixiv\.net/img-zip-ugoira/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/\d+_ugoira\d+x\d+\.zip\z!i + if url =~ %r!\Ahttps?://i\d+\.pixiv\.net/img-zip-ugoira/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/\d+_ugoira\d+x\d+\.zip\z!i data[:ugoira_frame_data] = source.ugoira_frame_data data[:ugoira_width] = source.ugoira_width data[:ugoira_height] = source.ugoira_height diff --git a/app/logical/pixiv_ugoira_service.rb b/app/logical/pixiv_ugoira_service.rb index c83e68a4a..a56de5abc 100644 --- a/app/logical/pixiv_ugoira_service.rb +++ b/app/logical/pixiv_ugoira_service.rb @@ -10,7 +10,8 @@ class PixivUgoiraService end def generate_resizes(source_path, output_path, preview_path) - PixivUgoiraConverter.delay(:queue => Socket.gethostname).convert(source_path, output_path, preview_path, @frame_data) + # Run this a bit in the future to give the upload process time to move the file + PixivUgoiraConverter.delay(:queue => Socket.gethostname, :run_at => 2.seconds.from_now).convert(source_path, output_path, preview_path, @frame_data) # since the resizes will be delayed, just touch the output file so the # file distribution wont break diff --git a/app/models/upload.rb b/app/models/upload.rb index 99c366da0..dcc17ef55 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -241,7 +241,8 @@ class Upload < ActiveRecord::Base if is_image? Danbooru.resize(source_path, output_path, width, height, quality) elsif is_ugoira? - ugoira_service.generate_resizes(source_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width)) + # by the time this runs we'll have moved source_path to md5_file_path + ugoira_service.generate_resizes(md5_file_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width)) elsif is_video? generate_video_preview_for(width, height, output_path) end @@ -374,7 +375,7 @@ class Upload < ActiveRecord::Base self.file_path = destination_path download = Downloads::File.new(source, destination_path, :is_ugoira => has_ugoira_tag?) download.download! - ugoira_service.load(download.data) + ugoira_service.load(download.data) if has_ugoira_tag? end end diff --git a/db/structure.sql b/db/structure.sql index d6e07ac4c..bed47fab6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3,7 +3,6 @@ -- SET statement_timeout = 0; -SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; @@ -422,8 +421,8 @@ CREATE TABLE advertisement_hits ( id integer NOT NULL, advertisement_id integer NOT NULL, ip_addr inet NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -460,8 +459,8 @@ CREATE TABLE advertisements ( height integer NOT NULL, file_name character varying(255) NOT NULL, is_work_safe boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -491,8 +490,8 @@ ALTER SEQUENCE advertisements_id_seq OWNED BY advertisements.id; CREATE TABLE amazon_backups ( id integer NOT NULL, last_id integer, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -558,8 +557,8 @@ CREATE TABLE artist_commentaries ( original_description text, translated_title text, translated_description text, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -595,8 +594,8 @@ CREATE TABLE artist_commentary_versions ( original_description text, translated_title text, translated_description text, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -628,8 +627,8 @@ CREATE TABLE artist_urls ( artist_id integer NOT NULL, url text NOT NULL, normalized_url text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -667,8 +666,8 @@ CREATE TABLE artist_versions ( group_name character varying(255), url_string text, is_banned boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -704,8 +703,8 @@ CREATE TABLE artists ( other_names text, other_names_index tsvector, group_name character varying(255), - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -738,8 +737,8 @@ CREATE TABLE bans ( reason text NOT NULL, banner_id integer NOT NULL, expires_at timestamp without time zone NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -805,8 +804,8 @@ CREATE TABLE comment_votes ( comment_id integer NOT NULL, user_id integer NOT NULL, score integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -841,8 +840,8 @@ CREATE TABLE comments ( ip_addr inet NOT NULL, body_index tsvector NOT NULL, score integer DEFAULT 0 NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, updater_id integer, updater_ip_addr inet, do_not_bump_post boolean DEFAULT false NOT NULL @@ -882,8 +881,8 @@ CREATE TABLE delayed_jobs ( locked_at timestamp without time zone, failed_at timestamp without time zone, locked_by character varying(255), - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, queue character varying(255) ); @@ -921,8 +920,8 @@ CREATE TABLE dmails ( message_index tsvector NOT NULL, is_read boolean DEFAULT false NOT NULL, is_deleted boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, creator_ip_addr inet DEFAULT '127.0.0.1'::inet NOT NULL ); @@ -1988,8 +1987,8 @@ CREATE TABLE forum_posts ( body text NOT NULL, text_index tsvector NOT NULL, is_deleted boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2091,8 +2090,8 @@ CREATE TABLE forum_topics ( is_locked boolean DEFAULT false NOT NULL, is_deleted boolean DEFAULT false NOT NULL, text_index tsvector NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, category_id integer DEFAULT 0 NOT NULL ); @@ -2125,8 +2124,8 @@ CREATE TABLE ip_bans ( creator_id integer NOT NULL, ip_addr inet NOT NULL, reason text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2158,8 +2157,8 @@ CREATE TABLE janitor_trials ( creator_id integer NOT NULL, user_id integer NOT NULL, original_level integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2190,8 +2189,8 @@ CREATE TABLE key_values ( id integer NOT NULL, key character varying(255) NOT NULL, value text, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2222,8 +2221,8 @@ CREATE TABLE mod_actions ( id integer NOT NULL, creator_id integer NOT NULL, description text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2255,8 +2254,8 @@ CREATE TABLE news_updates ( message text NOT NULL, creator_id integer NOT NULL, updater_id integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2295,8 +2294,8 @@ CREATE TABLE note_versions ( height integer NOT NULL, is_active boolean DEFAULT true NOT NULL, body text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, version integer DEFAULT 0 NOT NULL ); @@ -2335,8 +2334,8 @@ CREATE TABLE notes ( is_active boolean DEFAULT true NOT NULL, body text NOT NULL, body_index tsvector NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, version integer DEFAULT 0 NOT NULL ); @@ -2401,8 +2400,8 @@ CREATE TABLE pool_versions ( post_ids text DEFAULT ''::text NOT NULL, updater_id integer NOT NULL, updater_ip_addr inet NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, name character varying(255) ); @@ -2439,8 +2438,8 @@ CREATE TABLE pools ( post_ids text DEFAULT ''::text NOT NULL, post_count integer DEFAULT 0 NOT NULL, is_deleted boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, category character varying(255) DEFAULT 'series'::character varying NOT NULL ); @@ -2474,8 +2473,8 @@ CREATE TABLE post_appeals ( creator_id integer NOT NULL, creator_ip_addr integer NOT NULL, reason text, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2506,8 +2505,8 @@ CREATE TABLE post_disapprovals ( id integer NOT NULL, user_id integer NOT NULL, post_id integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2541,8 +2540,8 @@ CREATE TABLE post_flags ( creator_ip_addr inet NOT NULL, reason text, is_resolved boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2571,8 +2570,8 @@ ALTER SEQUENCE post_flags_id_seq OWNED BY post_flags.id; CREATE TABLE post_versions ( id integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, post_id integer NOT NULL, tags text DEFAULT ''::text NOT NULL, rating character(1), @@ -2611,8 +2610,8 @@ CREATE TABLE post_votes ( post_id integer NOT NULL, user_id integer NOT NULL, score integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2641,8 +2640,8 @@ ALTER SEQUENCE post_votes_id_seq OWNED BY post_votes.id; CREATE TABLE posts ( id integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, up_score integer DEFAULT 0 NOT NULL, down_score integer DEFAULT 0 NOT NULL, score integer DEFAULT 0 NOT NULL, @@ -2757,8 +2756,8 @@ CREATE TABLE tag_aliases ( creator_ip_addr inet NOT NULL, forum_topic_id integer, status text DEFAULT 'pending'::text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2794,8 +2793,8 @@ CREATE TABLE tag_implications ( creator_ip_addr inet NOT NULL, forum_topic_id integer, status text DEFAULT 'pending'::text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2831,8 +2830,8 @@ CREATE TABLE tag_subscriptions ( is_public boolean DEFAULT true NOT NULL, last_accessed_at timestamp without time zone, is_opted_in boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2866,8 +2865,8 @@ CREATE TABLE tags ( category integer DEFAULT 0 NOT NULL, related_tags text, related_tags_updated_at timestamp without time zone, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, is_locked boolean DEFAULT false NOT NULL ); @@ -2900,8 +2899,8 @@ CREATE TABLE transaction_log_items ( category character varying(255), user_id integer, data text, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -2941,8 +2940,8 @@ CREATE TABLE uploads ( backtrace text, post_id integer, md5_confirmation character varying(255), - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, server text, parent_id integer ); @@ -2977,8 +2976,8 @@ CREATE TABLE user_feedback ( creator_id integer NOT NULL, category character varying(255) NOT NULL, body text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -3014,8 +3013,8 @@ CREATE TABLE user_name_change_requests ( desired_name character varying(255), change_reason text, rejection_reason text, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -3046,8 +3045,8 @@ CREATE TABLE user_password_reset_nonces ( id integer NOT NULL, key character varying(255) NOT NULL, email character varying(255) NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL ); @@ -3076,8 +3075,8 @@ ALTER SEQUENCE user_password_reset_nonces_id_seq OWNED BY user_password_reset_no CREATE TABLE users ( id integer NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, name character varying(255) NOT NULL, password_hash character varying(255) NOT NULL, email character varying(255), @@ -3135,8 +3134,8 @@ CREATE TABLE wiki_page_versions ( title character varying(255) NOT NULL, body text NOT NULL, is_locked boolean NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, other_names text ); @@ -3171,8 +3170,8 @@ CREATE TABLE wiki_pages ( body text NOT NULL, body_index tsvector NOT NULL, is_locked boolean DEFAULT false NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, updater_id integer, other_names text, other_names_index tsvector