def protect_path(path, path_type='files'): """Get a path based on permitted paths""" f = type_to_path.get(path_type) if f is not None: permitted = f() elif path_type.endswith('shares'): permitted = join_path(root_dir, path_type) print(permitted) try: real_path = get_real_path(permitted, path) return real_path except IOError: raise abort(403)
def list_shared(user, uid, path='.'): """If the path is a file: return it's content if the path is a folder: return a list of files in the folder if parameter 'format' is specified return the path in the specified format (zip only for now) """ real_shared_path = get_path_from_uid(user, uid) # print(real_shared_path) permitted = join_path(root_dir, real_shared_path) try: real_path = get_real_path(permitted, path) except IOError: abort(403, PATH_ERROR) # print("getting {}".format(real_path)) print(request.GET.keys()) if request.GET.get('format', 'raw').strip() == 'zip': print('got zip') archive = archive_path(real_path) return list_dir(archive) return list_dir(real_path)