Commit 2f2e0214 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

[filesystem] updated creation methods to propagate exceptoions

e.g. permission denied
parent 2222c3ef
......@@ -172,7 +172,9 @@ class FSAjaxController(AbstractController):
fs = self.get('fs')
self.release_database()
fs.create_folder(path, name)
err = fs.create_folder(path, name)
if err:
raise AjaxException(err)
@cherrypy.expose
@cherrypy.tools.method(accept="POST")
......@@ -181,7 +183,9 @@ class FSAjaxController(AbstractController):
fs = self.get('fs')
self.release_database()
fs.create_file(path, name)
err = fs.create_file(path, name)
if err:
raise AjaxException(err)
@cherrypy.expose
@cherrypy.tools.method(accept="POST")
......
......@@ -295,27 +295,24 @@ class FileSystem(object):
path = self.expand(path)
name = self.expand(name)
# folder with the same name existent?
name = self.handle_file_name_collision(name, path)
fullpath = os.path.join(path, name)
try:
os.mkdir(fullpath)
except Exception as e:
# raise Exception("You don't have the permission to create this folder!")
raise Exception(str(e))
return str(e)
return ""
def create_file(self, path, name):
path = self.expand(path)
name = self.expand(name)
# file with the same name existent?
name = self.handle_file_name_collision(name, path)
fullpath = os.path.join(path, name)
try:
f = file(fullpath, "w")
f.close()
with file(fullpath, "w") as f:
pass
except Exception as e:
raise Exception(str(e))
return str(e)
return ""
def rename(self, path, name, new_name, force=False):
path = self.expand(path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment