api: add upload_hash for checking file hash before uploading

This commit is contained in:
Kyle Drake 2017-05-21 17:32:26 -05:00
parent 7d17202f39
commit 4a2926508e
3 changed files with 55 additions and 0 deletions

View file

@ -1512,6 +1512,12 @@ class Site < Sequel::Model
save_changes validate: false
end
def sha1_hash_match?(path, sha1_hash)
relative_path = scrubbed_path path
site_file = site_files_dataset.where(path: relative_path, sha1_hash: sha1_hash).first
!site_file.nil?
end
private
def store_file(path, uploaded, opts={})