Skip to content
Snippets Groups Projects
Verified Commit 609907e9 authored by tribut's avatar tribut :man_dancing:
Browse files

Only download files when they don't exist yet

parent 72c27559
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,11 @@ class FiledropFile < ApplicationRecord ...@@ -17,7 +17,11 @@ class FiledropFile < ApplicationRecord
end end
def download(url) def download(url)
# TBD: only download if orig_created is newer than actual file change time if File.exist?(local_path)
local_sha1 = Digest::SHA1.file(local_path).hexdigest
return if local_sha1 == checksum
end
response = HTTParty.get(url) response = HTTParty.get(url)
if response.success? if response.success?
File.open(local_path, 'wb') do |file| File.open(local_path, 'wb') do |file|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment