mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2025-02-18 11: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
|
from django.conf import settings
|
||||||
os.umask(0)
|
os.umask(0)
|
||||||
path = 'helpdesk/attachments/%s/%s' % (instance.followup.ticket.ticket_for_url, instance.followup.id )
|
path = 'helpdesk/attachments/%s/%s' % (instance.followup.ticket.ticket_for_url, instance.followup.id )
|
||||||
try:
|
att_path = os.path.join(settings.MEDIA_ROOT, path)
|
||||||
os.makedirs(os.path.join(settings.MEDIA_ROOT, path), 0777)
|
if not os.path.exists(att_path):
|
||||||
except OSError,e:
|
os.makedirs(att_path, 0777)
|
||||||
if e[0] != 17:
|
|
||||||
# 17 = 'File exists'
|
|
||||||
raise e
|
|
||||||
return os.path.join(path, filename)
|
return os.path.join(path, filename)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user