mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-14 01:58:28 +02: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:
@ -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)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user