You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/zip_pack.rb

18 lines
488 B

6 years ago
class ZipPack < ApplicationRecord
def self.packed?(bid, user_id, digests)
zip_pack = ZipPack.where(container_id: bid.id, container_type: bid.class.to_s, user_id: user_id).first
return false unless zip_pack && zip_pack.digests == digests
zip_pack
end
def file_valid?
return false unless File.exist?(self.file_path)
Educoder::Utils.digest(self.file_path) == self.file_digest
end
def digests
self.file_digests.split(',').sort
end
end