Merge pull request #995 from cweider/fix-caching

Fix cache headers for missing files.
pull/740/merge
John McLear 2012-09-12 04:48:09 -07:00
commit f105cf2646
1 changed files with 11 additions and 13 deletions

View File

@ -284,8 +284,14 @@ function getAceFile(callback) {
} }
// Check for the existance of the file and get the last modification date. // Check for the existance of the file and get the last modification date.
function statFile(filename, callback) { function statFile(filename, callback, dirStatLimit) {
if (filename == 'js/ace.js') { 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 // Sometimes static assets are inlined into this file, so we have to stat
// everything. // everything.
lastModifiedDateOfEverything(function (error, date) { lastModifiedDateOfEverything(function (error, date) {
@ -298,17 +304,9 @@ function statFile(filename, callback) {
if (error) { if (error) {
if (error.code == "ENOENT") { if (error.code == "ENOENT") {
// Stat the directory instead. // Stat the directory instead.
fs.stat(path.dirname(ROOT_DIR + filename), function (error, stats) { statFile(path.dirname(filename), function (error, date, exists) {
if (error) { callback(error, date, false);
if (error.code == "ENOENT") { }, dirStatLimit-1);
callback(null, null, false);
} else {
callback(error);
}
} else {
callback(null, stats.mtime.getTime(), false);
}
});
} else { } else {
callback(error); callback(error);
} }