mirror of
https://github.com/amark/gun.git
synced 2025-06-03 20:56:43 +00:00
file serve stats
This commit is contained in:
parent
105d81f7a6
commit
9a3225e387
5
gun.js
5
gun.js
@ -711,6 +711,7 @@
|
||||
if(!msg){ return }
|
||||
var ctx = msg._||'', root = ctx.root = ((msg.$||'')._||'').root;
|
||||
var put = msg.put, id = msg['#'], err, tmp;
|
||||
var DBG = ctx.DBG = msg.DBG;
|
||||
if(put['#']){ root.on('put', msg); return }
|
||||
/*root.on(id, function(m){
|
||||
console.log('ack:', m);
|
||||
@ -733,6 +734,7 @@
|
||||
}
|
||||
if(err){ break }
|
||||
}
|
||||
DBG && (DBG.p = +new Date);
|
||||
if(console.STAT){ console.STAT(S, +new Date - S, 'mix');console.STAT(S, ctx.lot.s, 'mix #') }
|
||||
if(ctx.err = err){ root.on('in', {'@': id, err: Gun.log(err)}); return }
|
||||
if(!(--ctx.lot.more)){ fire(ctx) } // if synchronous.
|
||||
@ -754,10 +756,11 @@
|
||||
}
|
||||
(lot = ctx.lot||'').s++; lot.more++;
|
||||
(ctx.stun || (ctx.stun = {}))[soul+key] = 1;
|
||||
var DBG = ctx.DBG; DBG && (DBG.ph = DBG.ph || +new Date);
|
||||
root.on('put', {'#': msg['#'], put: {'#': soul, '.': key, ':': val, '>': state}, _: ctx});
|
||||
}
|
||||
function map(msg){
|
||||
(msg._||'').DBG && ((msg._||'').DBG.m = +new Date);
|
||||
var DBG; if(DBG = (msg._||'').DBG){ DBG.pa = +new Date; DBG.pm = DBG.pm || +new Date}
|
||||
var eve = this, root = eve.as, graph = root.graph, ctx = msg._, put = msg.put, soul = put['#'], key = put['.'], val = put[':'], state = put['>'], id = msg['#'], tmp;
|
||||
graph[soul] = state_ify(graph[soul], key, state, val, soul); // TODO: Only put in graph if subscribed? Relays vs Browsers?
|
||||
chain(ctx, soul, key, (u !== (tmp = put['=']))? tmp : val, state); // TODO: This should NOT be how the API works, this should be done at an extension layer, but hacky solution to migrate with old code for now.
|
||||
|
@ -59,7 +59,7 @@
|
||||
r.parse(file, s.mix);
|
||||
}
|
||||
s.mix = function(err, disk){
|
||||
if(s.err = err || s.err){ console.log("????", cb, "????"); cb(err); return } // TODO: HANDLE BATCH EMIT
|
||||
if(s.err = err || s.err){ cb(err); return } // TODO: HANDLE BATCH EMIT
|
||||
var file = s.file = (disk||'').file || s.file, tmp;
|
||||
if(!disk && file !== opt.code.from){ // corrupt file?
|
||||
r.find.bad(file); // remove from dir list
|
||||
|
@ -32,8 +32,9 @@ function serve(req, res, next){ var tmp;
|
||||
fs.readdir(path, function(err, dir){ res.end((dir || (err && 404))+'') });
|
||||
return true;
|
||||
}
|
||||
var S = +new Date;
|
||||
var rs = fs.createReadStream(path);
|
||||
rs.on('open', function(){ rs.pipe(res) });
|
||||
rs.on('open', function(){ console.STAT && console.STAT(S, +new Date - S, 'serve open file'); rs.pipe(res) });
|
||||
rs.on('error', function(err){ res.end(404+'') });
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user