summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/uploaders/image_uploader.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb
index b1011d0..0c5eca3 100644
--- a/app/uploaders/image_uploader.rb
+++ b/app/uploaders/image_uploader.rb
@@ -94,6 +94,12 @@ class ImageUploader < CarrierWave::Uploader::Base
sha512_hash = Digest::SHA512.file(file.file).hexdigest
finished_time = Time.zone.now
+
+ model.post.update_columns(
+ processed: true, updated_at: finished_time
+ )
+
+ # automatically merge into existing image with duplicate hash
duplicate_image = Post::Image.includes(:post).find_by(sha512_hash: sha512_hash)
if duplicate_image
@@ -107,10 +113,6 @@ class ImageUploader < CarrierWave::Uploader::Base
updated_at: finished_time
)
- model.post.update_columns(
- processed: true, updated_at: finished_time
- )
-
IndexUpdateJob.perform_later('Post', model.post.id) # we index the processed:true and search on it, so we need to update the index here.
true