Commit 6e410949 authored by murban's avatar murban
Browse files

Raise warning when trying to access a folder without permission. Fix a small...

Raise warning when trying to access a folder without permission. Fix a small bug in the remote filesystem: Line indentation of the parentfolder has been wrong
parent 0ab07dc2
......@@ -89,19 +89,6 @@ class FSAjaxController(AbstractController):
vispa.log_exception()
return self.fail(msg='Couldn\'t load files: %s' % str(e), encode_json=True)
@cherrypy.expose
@cherrypy.tools.allow(methods=['POST', 'GET'])
@cherrypy.tools.json_out()
def folderup(self, path):
try:
path = os.path.expanduser(os.path.expandvars(path))
path = path[:-1] if path.endswith(os.sep) and path!=os.sep else path
path = os.path.dirname(path)
path = self.convert(path, 'string')
return self.success({'folderuppath': path})
except Exception, e:
return self.fail(msg='Couldn\'t load files: %s' % str(e))
@cherrypy.expose
@cherrypy.tools.allow(methods=['POST', 'GET'])
@cherrypy.tools.json_out()
......
......@@ -72,38 +72,41 @@ class FileSystem(object):
def get_file_list(self, path, deep=False, filter=[], reverse=False, hide_hidden=True, encode_json=False):
filelist = []
path_expand = os.path.expanduser(os.path.expandvars(path))
for elem in os.listdir(path_expand):
# hide hidden files?
if elem.startswith('.') and hide_hidden:
continue
# excluded by filters?
match = False
for filter_elem in filter:
if re.search(filter_elem, elem):
match = True
if match != reverse:
continue
fullpath = os.path.join(path_expand, elem)
# get locales, mtime, etc
locale.setlocale(locale.LC_ALL, '')
stats = os.stat(path_expand)
size = locale.format('%d', stats.st_size, grouping=True)
mtime = datetime.fromtimestamp(stats.st_mtime).strftime('%Y-%m-%d %H:%M:%S')
if os.path.isdir(fullpath):
filelist.append({'name': elem, 'type': 'd', 'parent': path, 'extension': '', 'mtime': mtime, 'size': size, 'path': fullpath})
if deep:
filelist.extend(self.get_file_list(fullpath, deep, filter, reverse))
else:
extension = elem.split('.')[-1]
filelist.append({'name': elem, 'type': 'f', 'parent': path, 'extension': extension, 'mtime': mtime, 'size': size, 'path': fullpath})
# Determine the parent
parentpath = path_expand[:-1] if path_expand.endswith(os.sep) and path_expand!=os.sep else path_expand
parentpath = os.path.dirname(path_expand)
try:
for elem in os.listdir(path_expand):
# hide hidden files?
if elem.startswith('.') and hide_hidden:
continue
# excluded by filters?
match = False
for filter_elem in filter:
if re.search(filter_elem, elem):
match = True
if match != reverse:
continue
fullpath = os.path.join(path_expand, elem)
# get locales, mtime, etc
locale.setlocale(locale.LC_ALL, '')
stats = os.stat(path_expand)
size = locale.format('%d', stats.st_size, grouping=True)
mtime = datetime.fromtimestamp(stats.st_mtime).strftime('%Y-%m-%d %H:%M:%S')
if os.path.isdir(fullpath):
filelist.append({'name': elem, 'type': 'd', 'parent': path, 'extension': '', 'mtime': mtime, 'size': size, 'path': fullpath})
if deep:
filelist.extend(self.get_file_list(fullpath, deep, filter, reverse))
else:
extension = elem.split('.')[-1]
filelist.append({'name': elem, 'type': 'f', 'parent': path, 'extension': extension, 'mtime': mtime, 'size': size, 'path': fullpath})
except Exception, e:
filelist.append({'warning': str(e)})
# Determine the parent
parentpath = path_expand[:-1] if path_expand.endswith(os.sep) and path_expand!=os.sep else path_expand
parentpath = os.path.dirname(path_expand)
data = {'filelist': filelist, 'parentpath': parentpath}
if encode_json:
return json.dumps(data)
......
......@@ -48,7 +48,11 @@ var Symbolview = Class.extend({
_this.owner.view.mainContainer.append(folderup);
$.each(data.filelist, function(i, file) {
var contentdiv = _this.makeIcon(file);
if (file.warning) {
alert(file.warning)
} else {
var contentdiv = _this.makeIcon(file);
};
// owner.view.mainContainer.isotope('insert', contentdiv);
_this.owner.view.mainContainer.append(contentdiv);
......
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