Skip to content

Commit

Permalink
Files uplaoded via LFE will no longer risk overwriting each other.
Browse files Browse the repository at this point in the history
  • Loading branch information
lethain committed Jun 2, 2008
1 parent af12629 commit b96fd63
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions editor/views.py
Expand Up @@ -15,7 +15,7 @@
"""


import datetime
import datetime, os.path
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.http import Http404, HttpResponseRedirect, HttpResponseServerError
Expand Down Expand Up @@ -215,7 +215,12 @@ def add_resource(request):
title = request.POST['title']
markdown_id = request.POST['markdown_id']
filename = file['filename']
fd = open('%s/lifeflow/resource/%s' %(settings.MEDIA_ROOT, filename), 'wb')
filebase = '%s/lifeflow/resource/' % settings.MEDIA_ROOT
filepath = "%s%s" % (filebase, filename)
while (os.path.isfile(filepath)):
filename = "_%s" % filename
filepath = "%s%s" % (filebase, filename)
fd = open(filepath, 'wb')
fd.write(file['content'])
fd.close()
rec = Resource(title=title, markdown_id=markdown_id, content="lifeflow/resource/%s" % filename)
Expand Down

0 comments on commit b96fd63

Please sign in to comment.