palewire/django-calaccess-raw-data

Size of the clean archive zip

Closed this issue · 3 comments

Can we create a field for the size of our new clean zip files for display on the version detail page?

We should probably do this.

Just realized: the django.db.models.fields.files.FieldFile instances have a .size property. Tested this out, and it works whether you are storing stuff in MEDIA_ROOT or using a custom django like an S3 bucket.

In [2]: from calaccess_raw.models.tracking import RawDataVersion

In [3]: v = RawDataVersion.objects.latest()

In [4]: v.download_zip_archive.size
Out[4]: 764366301

In [5]: v.clean_zip_archive.size
Out[5]: 789222001

So I added a .pretty_clean_size() method to RawDataVersion that uses this lower level method instead of adding a new field for tracking the size.

If that's a workable solution, then I actually think we should go back and drop all these various size fields so that we won't have to track it in the db and risk the possibility of it somehow getting out of sync with the actual file size.

Make sense? Also, happy to help in switching over the downloads-website to using these methods if we decide to go that route.

Makes sense to me. Already switched the website, should start working on next release of the raw data app.