From d5055ee87d2400bdba1befd0cefb579427116961 Mon Sep 17 00:00:00 2001 From: tr4ck3ur Date: Sat, 31 Oct 2015 17:31:03 +0100 Subject: [PATCH] try to fix strange issue with upload --- jm2l/upload.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/jm2l/upload.py b/jm2l/upload.py index b6413bc..7f0d623 100644 --- a/jm2l/upload.py +++ b/jm2l/upload.py @@ -100,44 +100,48 @@ class MediaPath(): slug = Place.by_id(linked_id).slug if media_table=='salle': slug = SallePhy.by_id(linked_id).slug - p = IMAGEPATH + [ media_table ] + [ slug ] + p = IMAGEPATH + [ media_table, slug ] elif media_table=='presse': # Use Year in linked_id - p = IMAGEPATH + [ media_table ] + [ linked_id ] + p = IMAGEPATH + [ media_table, linked_id ] elif media_table=='tasks': # Use Current Year - p = IMAGEPATH + [ str(CurrentYear), media_table ] + [ linked_id ] + p = IMAGEPATH + [ str(CurrentYear), media_table, linked_id ] elif media_table=='poles': # Use Current Year - p = IMAGEPATH + [ str(CurrentYear), media_table ] + [ linked_id ] + p = IMAGEPATH + [ str(CurrentYear), media_table, linked_id ] elif media_table in ['RIB', 'Justif']: slug = User.by_id(linked_id).slug - p = IMAGEPATH + ['users'] + [ slug ] + [ self.media_table ] + p = IMAGEPATH + ['users', slug , media_table ] elif media_table=='users': user = User.by_id(linked_id) if not user: raise HTTPNotFound() else: slug = user.slug - p = IMAGEPATH + ['users'] + [ slug ] + p = IMAGEPATH + ['users', slug ] elif media_table=='badge': user = User.by_id(linked_id) if not user: raise HTTPNotFound() else: slug = user.slug - p = IMAGEPATH + ['badge'] + [ slug ] + p = IMAGEPATH + ['badge', slug ] elif media_table=='event': ev = Event.by_id(linked_id) slug = ev.slug year = ev.for_year - p = IMAGEPATH + ['event'] + [ str(year) ] + [ slug ] + p = IMAGEPATH + ['event', str(year), slug ] if name: p += [ name ] TargetPath = os.path.join('jm2l/upload', *p) if not os.path.isdir(os.path.dirname(TargetPath)): - os.makedirs(os.path.dirname(TargetPath)) + try: + os.makedirs(os.path.dirname(TargetPath)) + except OSError, e: + if e.errno != 17: + raise e return os.path.join('jm2l/upload', *p) def ExtMimeIcon(self, mime):