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.
19 lines
475 B
19 lines
475 B
6 years ago
|
class ZipPack < ActiveRecord::Base
|
||
|
# attr_accessible :title, :body
|
||
|
|
||
|
def self.packed?(bid_id, user_id, digests)
|
||
|
zip_pack = ZipPack.where(homework_id: bid_id, 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)
|
||
|
Trustie::Utils.digest(self.file_path) == self.file_digest
|
||
|
end
|
||
|
|
||
|
def digests
|
||
|
self.file_digests.split(',').sort
|
||
|
end
|
||
|
end
|