Skip to content

Commit

Permalink
measure file size in kilobytes (bug 620864)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Balogh committed Dec 28, 2010
1 parent 0d027f3 commit a2b4353
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/files/models.py
Expand Up @@ -87,7 +87,7 @@ def from_upload(cls, upload, version, platform, parse_data={}):
f = cls(version=version, platform=platform)
upload.path = path.path(nfd_str(upload.path))
f.filename = f.generate_filename(extension=upload.path.ext)
f.size = upload.path.size
f.size = int(max(1, round(upload.path.size / 1024, 0))) # Kilobytes.
f.jetpack = cls.is_jetpack(upload.path)
f.hash = upload.hash
f.no_restart = parse_data.get('no_restart', False)
Expand Down
10 changes: 10 additions & 0 deletions apps/files/tests.py
Expand Up @@ -372,6 +372,16 @@ def test_utf8(self):
f = File.from_upload(upload, self.version, self.platform)
eq_(f.filename, u'jéts-0.1-mac.xpi')

def test_size(self):
upload = self.upload('extension')
f = File.from_upload(upload, self.version, self.platform)
eq_(f.size, 2)

def test_size_small(self):
upload = self.upload('alt-rdf')
f = File.from_upload(upload, self.version, self.platform)
eq_(f.size, 1)


class TestZip(test_utils.TestCase):

Expand Down

0 comments on commit a2b4353

Please sign in to comment.