def tell(path): entries = [] base = os.path.join(config["juno-base"], "root") path = os.path.join(base, safepath(path)) dirpath, dirnames, filenames = os.walk(path).next() for i in sorted(dirnames): subpath = "/" + os.path.relpath(os.path.join(path, i), base) entries.append({ "text": i, "id": subpath, "can_write_parent": auth.can_write_parent(subpath[1:]), "can_write": auth.can_write(subpath[1:]) }) for i in sorted(filenames): if i[0] == ".": continue subpath = "/" + os.path.relpath(os.path.join(path, i), base) entries.append({ "text": i, "id": subpath, "can_write_parent": auth.can_write_parent(subpath[1:]), "can_write": auth.can_write(subpath[1:]), "leaf": "true" }) return json.dumps(entries)
def POST(self, path): path = safepath(path) if not auth.can_write_parent(path): return error("Unauthorized") srcp = common.Mapper.d2s(path) if not srcp.startswith(config["juno-home"] + "/"): return error("Unauthorized") if not os.path.isfile(srcp): return error("Unauthorized") index.workerid = 0 index.config = config index.del_preso(web.ctx.db, srcp) os.unlink(srcp)
def POST(self, path): path = safepath(path) if not auth.can_write_parent(path): return error("Unauthorized") srcp = common.Mapper.d2s(path) if not srcp.startswith(config["juno-home"] + "/"): return error("Unauthorized") base = os.path.join(config["juno-base"], "root") dstp = os.path.join(base, common.Mapper.s2d(srcp)) if not os.path.isdir(srcp) or os.listdir(srcp) or os.listdir(dstp): return error("Unauthorized") os.rmdir(srcp) os.rmdir(dstp)