mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 02:10:49 +01:00
Fixes issue #48: when saving attachments, the 'path exists' checking was not
compatible with Windows. This patch is a much cleaner way of checking the path before creating it, rather than relying on an exception which we were previously doing. Thanks to 'rukeba' for the patch.
This commit is contained in:
parent
f6be2403f5
commit
9e13b42a4d
@ -552,12 +552,9 @@ def attachment_path(instance, filename):
|
||||
from django.conf import settings
|
||||
os.umask(0)
|
||||
path = 'helpdesk/attachments/%s/%s' % (instance.followup.ticket.ticket_for_url, instance.followup.id )
|
||||
try:
|
||||
os.makedirs(os.path.join(settings.MEDIA_ROOT, path), 0777)
|
||||
except OSError,e:
|
||||
if e[0] != 17:
|
||||
# 17 = 'File exists'
|
||||
raise e
|
||||
att_path = os.path.join(settings.MEDIA_ROOT, path)
|
||||
if not os.path.exists(att_path):
|
||||
os.makedirs(att_path, 0777)
|
||||
return os.path.join(path, filename)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user