Skip to content
Browse files

Last modification is more specific (when possible).

  • Loading branch information...
1 parent 3da1464 commit a5006255b7f4a6454dc2368b597ec44de824d3da @cweider committed Feb 5, 2012
Showing with 26 additions and 3 deletions.
  1. +26 −3 node/utils/Minify.js
View
29 node/utils/Minify.js
@@ -54,7 +54,7 @@ exports.minifyJS = function(req, res, next)
var filename = req.params['filename'];
res.header("Content-Type","text/javascript");
- lastModifiedDate(function (date) {
+ lastModifiedDateOf(filename, function (error, date) {
date = new Date(date);
res.setHeader('last-modified', date.toUTCString());
res.setHeader('date', (new Date()).toUTCString());
@@ -161,7 +161,30 @@ function getAceFile(callback) {
});
}
-function lastModifiedDate(callback) {
+function lastModifiedDateOf(filename, callback) {
+ if (filename == 'ace.js') {
+ lastModifiedDateOfEverything(callback);
+ } else {
+ fs.stat(JS_DIR + filename, function (error, stats) {
+ if (error) {
+ if (error.code == "ENOENT") { // Stat the directory instead.
+ fs.stat(JS_DIR, function (error, stats) {
+ if (error) {
+ callback(error);
+ } else {
+ callback(null, stats.mtime.getTime());
+ }
+ });
+ } else {
+ callback(error);
+ }
+ } else {
+ callback(null, stats.mtime.getTime());
+ }
+ });
+ }
+}
+function lastModifiedDateOfEverything(callback) {
var folders2check = [CSS_DIR, JS_DIR];
var latestModification = 0;
//go trough this two folders
@@ -197,7 +220,7 @@ function lastModifiedDate(callback) {
}, callback);
});
}, function () {
- callback(latestModification);
+ callback(null, latestModification);
});
}

0 comments on commit a500625

Please sign in to comment.
Something went wrong with that request. Please try again.