Fix zip saving bug
This commit is contained in:
parent
e5560cd6e9
commit
a19bfefa8c
1 changed files with 3 additions and 3 deletions
|
@ -76,8 +76,8 @@ class ProblemData(models.Model):
|
||||||
self.__original_zipfile = self.zipfile
|
self.__original_zipfile = self.zipfile
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.zipfile != self.__original_zipfile and self.__original_zipfile:
|
|
||||||
# Delete caches
|
# Delete caches
|
||||||
|
if self.__original_zipfile:
|
||||||
try:
|
try:
|
||||||
files = ZipFile(self.__original_zipfile.path).namelist()
|
files = ZipFile(self.__original_zipfile.path).namelist()
|
||||||
for file in files:
|
for file in files:
|
||||||
|
@ -85,7 +85,7 @@ class ProblemData(models.Model):
|
||||||
cache.delete(cache_key)
|
cache.delete(cache_key)
|
||||||
except BadZipFile:
|
except BadZipFile:
|
||||||
pass
|
pass
|
||||||
|
if self.zipfile != self.__original_zipfile and self.__original_zipfile:
|
||||||
self.__original_zipfile.delete(save=False)
|
self.__original_zipfile.delete(save=False)
|
||||||
return super(ProblemData, self).save(*args, **kwargs)
|
return super(ProblemData, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue