Skip to content

Commit

Permalink
preserve file order for concats
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajs89 committed Nov 10, 2012
1 parent 2e780a5 commit 93f13a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Jairaj Sethi <j@jairaj.org> (http://jairaj.org/)",
"name": "zerver",
"description": "client-integrated webapp server",
"version": "0.6.2",
"version": "0.6.3",
"repository": {
"type": "git",
"url": "git://github.com/jairajs89/zerver.git"
Expand Down
40 changes: 20 additions & 20 deletions zerver.js
Expand Up @@ -544,29 +544,28 @@ function concatRequest (handler, pathname) {
file = '';

files.forEach(function (fileName) {
fs.readFile(path.join(ROOT_DIR, fileName), function (err, data) {
if (err) {
hasError = true;
}
else {
file += data;
}

if ( !--filesLeft ) {
finish();
}
});
});

function finish () {
if (hasError) {
respond404(handler);
return;
}
else {
respondBinary(handler, 200, mime.lookup(pathname), file, {
'Cache-Control' : CACHE_CONTROL
});

try {
var data = fs.readFileSync( path.join(ROOT_DIR, fileName) );
}
catch (err) {
hasError = true;
return;
}

file += data;
});

if (hasError) {
respond404(handler);
}
else {
respondBinary(handler, 200, mime.lookup(pathname), file, {
'Cache-Control' : CACHE_CONTROL
});
}
}

Expand Down Expand Up @@ -798,6 +797,7 @@ function logRequest (handler, status) {
if (agent) {
console.log(agent);
}
//TODO: print referer
console.log('');
}
}
Expand Down

0 comments on commit 93f13a7

Please sign in to comment.