Skip to content

Instantly share code, notes, and snippets.

@ctalkington
Created January 25, 2014 01:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctalkington/75fe3fd75ef835af75e4 to your computer and use it in GitHub Desktop.
Save ctalkington/75fe3fd75ef835af75e4 to your computer and use it in GitHub Desktop.
archive = archiver(type, {zlib: { level: config.zipLevel }, catchEarly: false});
archive.on("error", function (error) { log.error(error); });
archive.pipe(res);
utils.walkDirectory(zipPath, true, function (error, paths) {
paths = paths.filter(function (s) { return s !== ""; });
if (error) log.error(error);
(function read(currentPath) {
if (currentPath[currentPath.length - 1] !== "/")
archive.file(currentPath, {name: removeFilePath(currentPath)}, next);
else
archive.append("", { name: removeFilePath(currentPath) }, next);
function next(error) {
if (error) log.error(error);
if (paths.length) {
read(paths.pop());
} else {
- archive.finalize(function (error) {
- if (error) log.error(error);
- res.end();
- });
+ archive.finalize();
}
}
})(paths.pop());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment