@@ -38,9 +38,9 @@ def create_thumbnail!
3838
3939 def self . create_for ( user_id , file )
4040 # compute the sha
41- sha = Digest ::SHA1 . file ( file . tempfile ) . hexdigest
41+ sha1 = Digest ::SHA1 . file ( file . tempfile ) . hexdigest
4242 # check if the file has already been uploaded
43- upload = Upload . where ( sha : sha ) . first
43+ upload = Upload . where ( sha1 : sha1 ) . first
4444
4545 # otherwise, create it
4646 if upload . blank?
@@ -53,25 +53,25 @@ def self.create_for(user_id, file)
5353 user_id : user_id ,
5454 original_filename : file . original_filename ,
5555 filesize : File . size ( file . tempfile ) ,
56- sha : sha ,
56+ sha1 : sha1 ,
5757 width : width ,
5858 height : height ,
5959 url : ""
6060 } )
6161 # make sure we're at the beginning of the file (FastImage is moving the pointer)
6262 file . rewind
6363 # store the file and update its url
64- upload . url = Upload . store_file ( file , sha , image_info , upload . id )
64+ upload . url = Upload . store_file ( file , sha1 , image_info , upload . id )
6565 # save the url
6666 upload . save
6767 end
6868 # return the uploaded file
6969 upload
7070 end
7171
72- def self . store_file ( file , sha , image_info , upload_id )
73- return S3 . store_file ( file , sha , image_info , upload_id ) if SiteSetting . enable_s3_uploads?
74- return LocalStore . store_file ( file , sha , image_info , upload_id )
72+ def self . store_file ( file , sha1 , image_info , upload_id )
73+ return S3 . store_file ( file , sha1 , image_info , upload_id ) if SiteSetting . enable_s3_uploads?
74+ return LocalStore . store_file ( file , sha1 , image_info , upload_id )
7575 end
7676
7777 def self . uploaded_regex
@@ -105,11 +105,11 @@ def self.asset_host
105105# url :string(255) not null
106106# created_at :datetime not null
107107# updated_at :datetime not null
108- # sha :string(255 )
108+ # sha1 :string(40 )
109109#
110110# Indexes
111111#
112- # index_uploads_on_sha (sha ) UNIQUE
112+ # index_uploads_on_sha1 (sha1 ) UNIQUE
113113# index_uploads_on_user_id (user_id)
114114#
115115
0 commit comments