REFACTOR: Refactor pull_hotlinked_images job

This commit should cause no functional change
- Split into functions to avoid deep nesting
- Register custom field type, and remove manual json parse/serialize
- Recover from deleted upload records

Also adds a test to ensure pull_hotlinked_images redownloads secure images only once
This commit is contained in:
David Taylor
2020-08-05 12:14:59 +01:00
committed by GitHub
parent aee3c2c34d
commit cb12a721c4
6 changed files with 144 additions and 131 deletions

View File

@ -178,21 +178,11 @@ class CookedPostProcessor
end
def large_images
@large_images ||=
begin
JSON.parse(@post.custom_fields[Post::LARGE_IMAGES].presence || "[]")
rescue JSON::ParserError
[]
end
@large_images ||= @post.custom_fields[Post::LARGE_IMAGES].presence || []
end
def broken_images
@broken_images ||=
begin
JSON.parse(@post.custom_fields[Post::BROKEN_IMAGES].presence || "[]")
rescue JSON::ParserError
[]
end
@broken_images ||= @post.custom_fields[Post::BROKEN_IMAGES].presence || []
end
def downloaded_images