When downloading several files or folders, name the archive 'item1[+n].zip', and ensure that filenames are encoded correctly

pull/315/head
Chris Brown 2016-05-17 14:40:29 +01:00
rodzic 09bf053920
commit fd96fc8f01
3 zmienionych plików z 13 dodań i 6 usunięć

Wyświetl plik

@ -59,6 +59,7 @@
],
"c9plugins": {
"c9.ide.language": "#79bcb2fe06",
"c9.ide.language.core": "#undefined",
"c9.ide.language.css": "#be07d72209",
"c9.ide.language.generic": "#3949510863",
"c9.ide.language.html": "#22fdc74869",

Wyświetl plik

@ -91,24 +91,30 @@ define(function(require, exports, module) {
}
function downloadProject() {
vfs.download("/", info.getWorkspace().name + getArchiveFileExtension());
vfs.download("/", makeArchiveFilename(info.getWorkspace().name));
}
function downloadPaths(paths) {
vfs.download(paths, info.getWorkspace().name + getArchiveFileExtension());
var lastPart = paths[0].match(/([^\/]*)\/?$/)[1];
var filename = lastPart ? (lastPart + "[+" + (paths.length - 1) + "]") : info.getWorkspace().name;
vfs.download(paths, makeArchiveFilename(filename));
}
function downloadFolder(path) {
var withTrailingSlash = path.replace(/\/*$/, "/");
var parts = withTrailingSlash.split("/");
var lastPart = parts[parts.length - 2];
vfs.download(withTrailingSlash, lastPart + getArchiveFileExtension());
var folderName = parts[parts.length - 2];
vfs.download(withTrailingSlash, makeArchiveFilename(folderName));
}
function downloadFile(path) {
vfs.download(path.replace(/\/*$/, ""), null, true);
}
function makeArchiveFilename(filename) {
return filename + getArchiveFileExtension();
}
function getArchiveFileExtension() {
var downloadFilesAs = settings.get(SETTING_PATH);
if (downloadFilesAs === 'auto' || !downloadFilesAs) {

Wyświetl plik

@ -193,12 +193,12 @@ define(function(require, exports, module) {
extraPaths = path;
path = path[0];
extraPaths = "," + extraPaths.map(function(p) {
return p[0] == path[0] && p != path ? escape(p) : "";
return p[0] == path[0] && p != path ? encodeURI(p) : "";
}).filter(Boolean).join(",");
}
window.open(vfsUrl(path) + extraPaths
+ "?download"
+ (filename ? "=" + escape(filename) : "")
+ (filename ? "=" + encodeURIComponent(filename) : "")
+ (isfile ? "&isfile=1" : ""));
}