Commit 0cbec7c0 authored by Fabian-Andree Heidemann's avatar Fabian-Andree Heidemann
Browse files

unzip in filebrowser, fix #1659

parent c12b880e
......@@ -207,6 +207,14 @@ class FSAjaxController(AbstractController):
paths = json.loads(paths)
fs.compress(path, paths, name)
@cherrypy.expose
@cherrypy.tools.ajax()
def decompress(self, file):
self.release_session()
fs = self.get('fs')
self.release_database()
fs.decompress(file)
@cherrypy.expose
@cherrypy.tools.ajax()
def paste(self, path, paths, cut):
......
......@@ -51,6 +51,20 @@ define(["jquery", "jclass"], function($, JClass) {
return;
}
if (ext !== null && ext.toLowerCase() == "zip") {
self.FileBase.instance.confirm(
"Do you want to decompress \"" + path.split("/").pop() + "\"?",
function(res) {
if (res) {
self.FileBase.instance.POST("/ajax/fs/decompress", {
"file": path
});
}
}
);
return;
}
var handlers = vispa.extensions.getFileHandlers(ext, true);
if (!handlers.length) {
......
......@@ -355,6 +355,23 @@ class FileSystem(object):
logger.debug(p)
archive.write(p, ap)
def decompress(self, file):
# filepath and extract path
filepath = self.expand(file)
path = filepath.rsplit(".zip", 1)[0]
# handle folder collision for extract path
while os.path.exists(path):
end = path.rsplit("/", 1)[1]
if len(end.split("_copy")) is not 1:
counter = int(end.rsplit("_copy", 1)[1])
counter += 1
path = path.rsplit("_copy", 1)[0] + "_copy" + str(counter)
else:
path = path + "_copy1"
with ZipFile(filepath, "r") as archive:
archive.extractall(path)
def paste(self, path, fullsrc, cut):
# TODO
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