diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-22 13:35:45 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:24 +0100 |
commit | 9d0bb012a463c7ce7805efd25888f938bb7d8867 (patch) | |
tree | 5681d0db3a55428e21f42696827942aa6aca8d34 /ishtar_common/models_imports.py | |
parent | 66b696717c21c46a14aa83636e655a9bfbbdb362 (diff) | |
download | Ishtar-9d0bb012a463c7ce7805efd25888f938bb7d8867.tar.bz2 Ishtar-9d0bb012a463c7ce7805efd25888f938bb7d8867.zip |
Imports: imported file not mandatory (when zipped can be null) - do not raise error if media file is missing
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r-- | ishtar_common/models_imports.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 5a3af1a05..7462f55be 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -939,7 +939,7 @@ class Import(models.Model): importer_type = models.ForeignKey(ImporterType) imported_file = models.FileField( _("Imported file"), upload_to="upload/imports/%Y/%m/", max_length=220, - help_text=max_size_help()) + help_text=max_size_help(), blank=True, null=True) imported_images = models.FileField( _("Associated images (zip file)"), upload_to="upload/imports/%Y/%m/", blank=True, null=True, max_length=220, help_text=max_size_help()) @@ -1438,7 +1438,10 @@ class Import(models.Model): for attr in file_attr: file_field = getattr(self, attr) if file_field: - os.remove(file_field.path) + try: + os.remove(file_field.path) + except FileNotFoundError: + pass setattr(self, attr, None) self.save() self._archive_pending = False |