summaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorChad Weider <cweider@oofn.net>2012-09-11 22:25:44 -0700
committerChad Weider <cweider@oofn.net>2012-09-11 22:27:14 -0700
commitfeeab5c1b25121e5fc5ae13681e24f0b55715628 (patch)
tree2bdb490f9bc904991b5cd407ae0bed296404a419 /src/node
parent70fe1a7451c7b69d446f5aee3ef8e0732844f461 (diff)
downloadetherpad-lite-feeab5c1b25121e5fc5ae13681e24f0b55715628.zip
Fix cache headers for missing files.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/utils/Minify.js24
1 files 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);
}