From 11ea9aef58d5197a02c8fe897ad1e25a8f697bd2 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 16 Oct 2017 12:49:25 -0400 Subject: [PATCH] Stop wasting time making extracted tarball trees read-only. Whatever benefits this may have had, a general purpose function like files.extractTarGz is definitely not the place for such an aggressive safety measure, and the performance penalty is significant, especially on Windows. --- tools/fs/files.js | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/tools/fs/files.js b/tools/fs/files.js index 5dd318c269..18c97e41a3 100644 --- a/tools/fs/files.js +++ b/tools/fs/files.js @@ -312,32 +312,6 @@ files.rm_recursive = Profile("files.rm_recursive", (path) => { } }); -// Makes all files in a tree read-only. -var makeTreeReadOnly = function (p) { - try { - // the l in lstat is critical -- we want to ignore symbolic links - var stat = files.lstat(p); - } catch (e) { - if (e.code == "ENOENT") { - return; - } - throw e; - } - - if (stat.isDirectory()) { - _.each(files.readdir(p), function (file) { - makeTreeReadOnly(files.pathJoin(p, file)); - }); - } - if (stat.isFile()) { - var permissions = stat.mode & 0o777; - var readOnlyPermissions = permissions & 0o555; - if (permissions !== readOnlyPermissions) { - files.chmod(p, readOnlyPermissions); - } - } -}; - // Returns the base64 SHA256 of the given file. files.fileHash = function (filename) { var crypto = require('crypto'); @@ -728,8 +702,7 @@ if (! process.env.METEOR_SAVE_TMPDIRS) { // Takes a buffer containing `.tar.gz` data and extracts the archive // into a destination directory. destPath should not exist yet, and // the archive should contain a single top-level directory, which will -// be renamed atomically to destPath. The entire tree will be made -// readonly. +// be renamed atomically to destPath. files.extractTarGz = function (buffer, destPath, options) { var options = options || {}; var parentDir = files.pathDirname(destPath); @@ -764,7 +737,6 @@ files.extractTarGz = function (buffer, destPath, options) { } var extractDir = files.pathJoin(tempDir, topLevelOfArchive[0]); - makeTreeReadOnly(extractDir); files.rename(extractDir, destPath); files.rm_recursive(tempDir);