A crash fix, and try to fill in gaps?
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3812 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
c57b0a2f2f
commit
a98a848bb7
20
core/ssb.js
20
core/ssb.js
@ -55,7 +55,11 @@ function followingDeep(db, seed_ids, depth) {
|
||||
function get_latest_sequence_for_author(author) {
|
||||
var sequence = 0;
|
||||
ssb.sqlStream(
|
||||
'SELECT MAX(sequence) AS sequence FROM messages WHERE author = ?1',
|
||||
'SELECT MIN(a.sequence) FROM messages a LEFT OUTER JOIN messages b ON a.author = b.author AND a.sequence + 1 = b.sequence WHERE a.author = ?1 AND b.content IS NULL',
|
||||
// TODO: Should we never have allowed inserting if we couldn't
|
||||
// validate previous? The query above helps us fill in gaps in
|
||||
// feeds.
|
||||
//'SELECT MAX(sequence) AS sequence FROM messages WHERE author = ?1',
|
||||
[author],
|
||||
function(row) {
|
||||
if (row.sequence) {
|
||||
@ -97,12 +101,14 @@ ssb.addEventListener('connections', function(change, connection) {
|
||||
connection.send_json({'name': ['blobs', 'createWants'], 'type': 'source', 'args': []}, function(message) {
|
||||
Object.keys(message.message).forEach(function(id) {
|
||||
if (message.message[id] < 0) {
|
||||
delete connection.active_blob_wants[id];
|
||||
var blob = ssb.blobGet(id);
|
||||
if (blob) {
|
||||
var out_message = {};
|
||||
out_message[id] = blob.byteLength;
|
||||
g_wants_requests[connection.id].send_json(out_message);
|
||||
if (g_wants_requests[connection.id]) {
|
||||
delete connection.active_blob_wants[id];
|
||||
var blob = ssb.blobGet(id);
|
||||
if (blob) {
|
||||
var out_message = {};
|
||||
out_message[id] = blob.byteLength;
|
||||
g_wants_requests[connection.id].send_json(out_message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var received_bytes = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user