diff options
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index e27b26e70..9b2f38819 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -52,6 +52,7 @@ from django.contrib.sessions.backends.db import SessionStore from django.core.cache import cache from django.core.exceptions import SuspiciousOperation, ObjectDoesNotExist from django.core.files import File +from django.core.files.storage import FileSystemStorage from django.core.validators import EMPTY_VALUES from django.core.urlresolvers import reverse from django.db import models @@ -2072,3 +2073,12 @@ def get_image_path(instance, filename): n = datetime.datetime.now() return "upload/{}/{:02d}/{:02d}/{}".format(n.year, n.month, n.day, filename) return instance._get_image_path(filename) + + +class IshtarFileSystemStorage(FileSystemStorage): + def exists(self, name): + path_name = self.path(name) + if os.path.islink(path_name): + if not os.path.exists(os.readlink(path_name)): + os.remove(path_name) + return os.path.exists(path_name) |