set the file hash from the FileUpload

This commit is contained in:
Jeff Balogh 2010-12-14 12:55:42 -08:00
Родитель 42de38f8e6
Коммит 43910d0944
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -87,10 +87,9 @@ class File(amo.models.ModelBase):
f.filename = f.generate_filename(extension=upload.path.ext)
f.size = upload.path.size
f.jetpack = cls.is_jetpack(upload.path)
# TODO: f.hash = upload.hash
f.hash = upload.hash
f.save()
log.debug('New file: %r from %r' % (f, upload))
# Detect addon-sdk-built addons.
# Move the uploaded file from the temp location.
dest = path.path(version.path_prefix)
if not dest.exists():

Просмотреть файл

@ -341,6 +341,11 @@ class TestFileFromUpload(UploadTest):
eq_(fv.warnings, 1)
eq_(fv.notices, 2)
def test_file_hash(self):
upload = self.upload('jetpack')
f = File.from_upload(upload, self.version, self.platform)
eq_(f.hash, upload.hash)
class TestZip(test_utils.TestCase):