UploadRecovery should recover attachments too.

This commit is contained in:
Guo Xiang Tan
2018-09-19 10:44:36 +08:00
parent 5a9b029014
commit 4a92c5b2d6
4 changed files with 63 additions and 23 deletions

View File

@ -168,6 +168,10 @@ class Upload < ActiveRecord::Base
Digest::SHA1.file(path).hexdigest
end
def self.extract_upload_url(url)
url.match(/(\/original\/\dX[\/\.\w]*\/([a-zA-Z0-9]+)[\.\w]*)/)
end
def self.get_from_url(url)
return if url.blank?
@ -177,7 +181,7 @@ class Upload < ActiveRecord::Base
end
return if uri&.path.blank?
data = uri.path.match(/(\/original\/\dX[\/\.\w]*\/([a-zA-Z0-9]+)[\.\w]*)/)
data = extract_upload_url(uri.path)
return if data.blank?
sha1 = data[2]
upload = nil