19 lines
493 B
Ruby
19 lines
493 B
Ruby
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
|