summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAppleDash <[email protected]>2023-04-27 20:51:08 -0400
committerAppleDash <[email protected]>2023-04-27 20:51:08 -0400
commit2fea8f908e899153ce93a90d0e717ecac5df54ea (patch)
tree4b3b84ebef9090a1c3045f8e62329afc6da57e06
parent50bf8e252fb6ffb91cf39039c31da48829a6b65f (diff)
-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