Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
If data file already exists in target worksheet, throw an error; fixe…
Browse files Browse the repository at this point in the history
…s google issue 84. Also, redirect to the data file page if there is an error.
  • Loading branch information
Jason Grout committed Dec 17, 2011
1 parent ceb3354 commit 188cd01
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flask_version/worksheet.py
Expand Up @@ -691,8 +691,10 @@ def worksheet_link_datafile(worksheet):
target = os.path.abspath(os.path.join(
target_ws.data_directory(), data_filename))
if target_ws.owner() != g.username and not target_ws.is_collaborator(g.username):
return current_app.message(_("illegal link attempt!"))
os.system('ln "%s" "%s"'%(src, target))
return current_app.message(_("illegal link attempt!"), worksheet_datafile.url_for(worksheet, name=data_filename))
if os.path.exists(target):
return current_app.message(_("The data filename already exists in other worksheet\nDelete the file in the other worksheet before creating a link."), worksheet_datafile.url_for(worksheet, name=data_filename))
os.link(src,target)
return redirect(worksheet_datafile.url_for(worksheet, name=data_filename))
#return redirect(url_for_worksheet(target_ws) + '/datafile?name=%s'%data_filename) #XXX: Can we not hardcode this?

Expand Down

0 comments on commit 188cd01

Please sign in to comment.