From 2abc5dee78ec29019175492f19552266990ae495 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 18 Dec 2014 21:08:14 +0000 Subject: [PATCH] Improve buffer allocation for copying files in utils/filesystem.js --- core/modules/utils/filesystem.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/filesystem.js b/core/modules/utils/filesystem.js index d7d084221..553209c6b 100644 --- a/core/modules/utils/filesystem.js +++ b/core/modules/utils/filesystem.js @@ -52,9 +52,13 @@ exports.copyDirectory = function(srcPath,dstPath) { Copy a file */ var FILE_BUFFER_LENGTH = 64 * 1024, - fileBuffer = $tw.node && new Buffer(FILE_BUFFER_LENGTH); + fileBuffer; exports.copyFile = function(srcPath,dstPath) { + // Create buffer if required + if(!fileBuffer) { + fileBuffer = new Buffer(FILE_BUFFER_LENGTH); + } // Create any directories in the destination $tw.utils.createDirectory(path.dirname(dstPath)); // Copy the file