summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/models.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index f3fda4e60..bdc621528 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -3258,12 +3258,16 @@ class IshtarImage(ImageModel):
reference_path = self._get_available_filename(
reference_path)
-
- os.rename(initial_path, reference_path)
- os.rename(self.thumbnail.path,
- self._get_thumb_name(reference_path))
- self.image.name = reference_path[len(settings.MEDIA_ROOT):]
- self.save(no_path_change=True)
+ try:
+ os.rename(initial_path, reference_path)
+ os.rename(self.thumbnail.path,
+ self._get_thumb_name(reference_path))
+ self.image.name = reference_path[
+ len(settings.MEDIA_ROOT):]
+ self.save(no_path_change=True)
+ except OSError:
+ # file probably not on harddrive - will be cleaned
+ pass
continue
# create a link
new_path = settings.MEDIA_ROOT + new_path