[Pkg-javascript-commits] [node-static] 128/151: Remove in-memory cache

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit 507e62e7585b4c02a2f9c9da124d2badcb02c920
Author: Dobes Vandermeer <dobesv at gmail.com>
Date:   Wed Nov 2 18:16:27 2011 +0800

    Remove in-memory cache
---
 lib/node-static.js | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 9300dc0..1119f72 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -10,12 +10,17 @@ var fs     = require('fs')
 // Current version
 var version = [0, 6, 9];
 
+<<<<<<< HEAD
 // In-memory file store
 var store      = {};
 var indexStore = {};
 
 Server = function (root, options) {
     if (root && (typeof(root) === 'object')) { options = root; root = null }
+=======
+this.Server = function (root, options) {
+    if (root && (typeof(root) === 'object')) { options = root, root = null }
+>>>>>>> Remove in-memory cache
 
     this.root    = path.resolve(root || '.');
     this.options = options || {};
@@ -65,6 +70,7 @@ Server.prototype.serveDir = function (pathname, req, res, finish) {
                 that.respond(null, status, headers, [htmlIndex], stat, req, res, finish);
             }
         } else {
+<<<<<<< HEAD
             if (pathname in indexStore) {
                 streamFiles(indexStore[pathname].files);
             } else {
@@ -76,6 +82,14 @@ Server.prototype.serveDir = function (pathname, req, res, finish) {
                     streamFiles(index.files);
                 });
             }
+=======
+            // Stream a directory of files as a single file.
+            fs.readFile(path.join(pathname, 'index.json'), function (e, contents) {
+                if (e) { return finish(404, {}) }
+                var index = JSON.parse(contents);
+                streamFiles(index.files);
+            });
+>>>>>>> Remove in-memory cache
         }
     });
     function streamFiles(files) {
@@ -224,7 +238,7 @@ this.Server.prototype.gzipOk = function(req, contentType) {
 }
 
 /* Send a gzipped version of the file if the options and the client indicate gzip is enabled and
- * we find a .gz file matching the static resource requested. 
+ * we find a .gz file mathing the static resource requested. 
  */
 this.Server.prototype.respondGzip = function(pathname, status, contentType, _headers, files, stat, req, res, finish) {
     var that = this;
@@ -283,6 +297,7 @@ this.Server.prototype.respondNoGzip = function (pathname, status, contentType, _
         finish(304, headers);
     } else {
 <<<<<<< HEAD
+<<<<<<< HEAD
         headers['content-length'] = stat.size;
         headers['content-type']   = mime.lookup(files[0]);
                                    'application/octet-stream';
@@ -313,6 +328,14 @@ this.Server.prototype.respondNoGzip = function (pathname, status, contentType, _
                 finish(status, headers);
             });
         }
+=======
+        res.writeHead(status, headers);
+
+        this.stream(pathname, files, new(buffer.Buffer)(stat.size), res, function (e, buffer) {
+            if (e) { return finish(500, {}) }
+            finish(status, headers);
+        });
+>>>>>>> Remove in-memory cache
     }
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list