From a19bfefa8c31b172cd97ef630b687098538d6199 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sat, 7 May 2022 20:06:39 -0500 Subject: [PATCH] Fix zip saving bug --- judge/models/problem_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/judge/models/problem_data.py b/judge/models/problem_data.py index 2cfb4f9..3735552 100644 --- a/judge/models/problem_data.py +++ b/judge/models/problem_data.py @@ -76,8 +76,8 @@ class ProblemData(models.Model): self.__original_zipfile = self.zipfile def save(self, *args, **kwargs): - if self.zipfile != self.__original_zipfile and self.__original_zipfile: - # Delete caches + # Delete caches + if self.__original_zipfile: try: files = ZipFile(self.__original_zipfile.path).namelist() for file in files: @@ -85,7 +85,7 @@ class ProblemData(models.Model): cache.delete(cache_key) except BadZipFile: pass - + if self.zipfile != self.__original_zipfile and self.__original_zipfile: self.__original_zipfile.delete(save=False) return super(ProblemData, self).save(*args, **kwargs)