From feeab5c1b25121e5fc5ae13681e24f0b55715628 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Tue, 11 Sep 2012 22:25:44 -0700 Subject: [PATCH] Fix cache headers for missing files. --- src/node/utils/Minify.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index ca3315a9..5fc8accb 100644 --- a/src/node/utils/Minify.js +++ b/src/node/utils/Minify.js @@ -284,8 +284,14 @@ function getAceFile(callback) { } // Check for the existance of the file and get the last modification date. -function statFile(filename, callback) { - if (filename == 'js/ace.js') { +function statFile(filename, callback, dirStatLimit) { + if (typeof dirStatLimit === 'undefined') { + dirStatLimit = 3; + } + + if (dirStatLimit < 1 || filename == '' || filename == '/') { + callback(null, null, false); + } else if (filename == 'js/ace.js') { // Sometimes static assets are inlined into this file, so we have to stat // everything. lastModifiedDateOfEverything(function (error, date) { @@ -298,17 +304,9 @@ function statFile(filename, callback) { if (error) { if (error.code == "ENOENT") { // Stat the directory instead. - fs.stat(path.dirname(ROOT_DIR + filename), function (error, stats) { - if (error) { - if (error.code == "ENOENT") { - callback(null, null, false); - } else { - callback(error); - } - } else { - callback(null, stats.mtime.getTime(), false); - } - }); + statFile(path.dirname(filename), function (error, date, exists) { + callback(error, date, false); + }, dirStatLimit-1); } else { callback(error); }