Skip to content

Commit

Permalink
Also don't crash when cleaning up temp dirs at the end of app run
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashko Stubailo committed Mar 31, 2015
1 parent 8d0627d commit 93fe5eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/non-core/npm-node-aes-gcm/.versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
meteor@1.1.6-rc.0
npm-node-aes-gcm@0.1.3-pre.win.3_6
npm-node-aes-gcm@0.1.3_6
underscore@1.0.3
14 changes: 13 additions & 1 deletion tools/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ files.freeTempDir = function (tempDir) {
// ignores all ENOENT calls. And we don't remove tempDir from tempDirs until
// it's done, so that if mid-way through this rm_recursive the onExit one
// fires, it still gets removed.

try {
files.rm_recursive(tempDir);
} catch (err) {
Expand All @@ -641,13 +642,24 @@ files.freeTempDir = function (tempDir) {
// unavoidable.
Console.debug(err);
}

tempDirs = _.without(tempDirs, tempDir);
});
};

if (! process.env.METEOR_SAVE_TMPDIRS) {
cleanup.onExit(function (sig) {
_.each(tempDirs, files.rm_recursive);
_.each(tempDirs, function (tempDir) {
try {
files.rm_recursive(tempDir);
} catch (err) {
// Don't crash and print a stack trace because we failed to delete a temp
// directory. This happens sometimes on Windows and seems to be
// unavoidable.
Console.debug(err);
}
});

tempDirs = [];
});
}
Expand Down

0 comments on commit 93fe5eb

Please sign in to comment.