Skip to content

Commit 38fc97d

Browse files
committed
Check against file corruption, and advance to v1.0 production.
1 parent fd750aa commit 38fc97d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
django-validated-file
22
=====================
33

4-
This Django app adds two field types, ValidatedFileField and ValidatedImageField, that add the
4+
This Django app adds a new field type, ValidatedFileField, that add the
55
capability of checking the document size and types the user may send.
66

77
Installation

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
setup(
1111
name = 'django-validated-file',
1212
version = ":versiontools:validatedfile:",
13-
description = "This Django app adds two field types, ValidatedFileField and ValidatedImageField, that add the capability of checking the document size and types the user may send.",
13+
description = "This Django app adds a new field type, ValidatedFileField, that add the capability of checking the document size and types the user may send.",
1414
long_description = "",
1515
keywords = 'django, filefield, validation',
1616
author = u'Andrés Moya Velázquez',
@@ -32,7 +32,7 @@
3232
],
3333
classifiers = [
3434
"Programming Language :: Python",
35-
'Development Status :: 2 - Pre-Alpha',
35+
'Development Status :: 5 - Production/Stable',
3636
'Framework :: Django',
3737
'Intended Audience :: Developers',
3838
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',

validatedfile/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = (0, 0, 1, "final", 0)
1+
__version__ = (1, 0, 0, "final", 0)
22

33
from django.db import models
44
from django import forms
@@ -13,7 +13,7 @@ def __init__(self, *args, **kwargs):
1313
self.max_upload_size = kwargs.pop("max_upload_size", 0)
1414
super(ValidatedFileField, self).__init__(*args, **kwargs)
1515

16-
def clean(self, *args, **kwargs):
16+
def clean(self, *args, **kwargs):
1717
data = super(ValidatedFileField, self).clean(*args, **kwargs)
1818
file = data.file
1919

@@ -47,7 +47,10 @@ def update(self, items, attr_name):
4747
for item in items:
4848
the_file = getattr(item, attr_name, None)
4949
if the_file:
50-
self.current_usage += the_file.size
50+
try:
51+
self.current_usage += the_file.size
52+
except AttributeError:
53+
pass # Protect against the inconsistence of that the file has been deleted in storage but still is in the field
5154

5255
def exceeds(self, size = 0):
5356
if self.max_usage >= 0:

0 commit comments

Comments
 (0)