diff --git a/lib/upload_recovery.rb b/lib/upload_recovery.rb index fba1a0073d2..ef13002d27b 100644 --- a/lib/upload_recovery.rb +++ b/lib/upload_recovery.rb @@ -51,7 +51,7 @@ class UploadRecovery private def recover_post_upload(post, sha1) - return unless sha1.present? + return unless sha1.present? && sha1.length == Upload::SHA1_LENGTH attributes = { post: post, diff --git a/spec/lib/upload_recovery_spec.rb b/spec/lib/upload_recovery_spec.rb index 40225d260e6..17240853400 100644 --- a/spec/lib/upload_recovery_spec.rb +++ b/spec/lib/upload_recovery_spec.rb @@ -55,6 +55,12 @@ RSpec.describe UploadRecovery do ) upload_recovery.recover + + post.update!( + raw: "test" + ) + + upload_recovery.recover end end