diff --git a/lib/client/dom.js b/lib/client/dom.js index 53f2eb45..2991048c 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -448,12 +448,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; RESTful.write(lDir + lName + lType, null, CloudCmd.refresh); } - /** - * zip file - * - */ - this.pack = function(current) { - var RESTful = DOM.RESTful, + function twopack(current, operation) { + var op, + nameDir = '', + nameFile = '', + RESTful = DOM.RESTful, + Images = DOM.Images, name = Cmd.getCurrentName(current), dir = Cmd.getCurrentDirPath(), path = dir + name, @@ -461,8 +461,40 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; from : path }; + Util.checkArgs(arguments, ['operation']); + + if (operation.pack) { + op = RESTful.zip; + nameDir = name + '.tar.gz'; + nameFile = name + '.gz'; + } else if (operation.unpack) { + op = RESTful.unzip; + nameDir = Util.rmStrOnce(name, '.tar.gz'); + nameFile = Util.rmStrOnce(name, '.gz'); + } + + Images.showLoad(); + if (name && name !== '..') - RESTful.zip(fileFrom, CloudCmd.refresh); + op(fileFrom, function() { + CloudCmd.refresh(null, null, function() { + var byName = DOM.getCurrentFileByName, + dir = byName(nameDir), + file = byName(nameFile); + + DOM.setCurrentFile(dir || file); + }); + }); + } + + /** + * zip file + * + */ + this.pack = function(current) { + twopack(current, { + pack: true + }); }; /** @@ -470,16 +502,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * */ this.unpack = function(current) { - var RESTful = DOM.RESTful, - name = Cmd.getCurrentName(current), - dir = Cmd.getCurrentDirPath(), - path = dir + name, - fileFrom = { - from : path - }; - - if (name && name !== '..') - RESTful.unzip(fileFrom, CloudCmd.refresh); + twopack(current, { + unpack: true + }); }; /**