FIX: Don't try to recover an invalid sha1.

This commit is contained in:
Guo Xiang Tan 2018-09-20 14:21:57 +08:00
parent df45e82377
commit 1a64b3a487
2 changed files with 7 additions and 1 deletions

View File

@ -51,7 +51,7 @@ class UploadRecovery
private private
def recover_post_upload(post, sha1) def recover_post_upload(post, sha1)
return unless sha1.present? return unless sha1.present? && sha1.length == Upload::SHA1_LENGTH
attributes = { attributes = {
post: post, post: post,

View File

@ -55,6 +55,12 @@ RSpec.describe UploadRecovery do
) )
upload_recovery.recover upload_recovery.recover
post.update!(
raw: "<a href=#{"/uploads/test/original/3X/a/6%0A/#{upload.sha1}.png"}>test</a>"
)
upload_recovery.recover
end end
end end