Differences From:
File
src/xfer.c
part of check-in
[0feed85090]
- Always do another sync round if any file is received.
by
drh on
2007-07-23 20:42:40.
[view]
To:
File
src/xfer.c
part of check-in
[23c8dad306]
- Delete records from the temporary table "pending" after sending them.
by
dan on
2007-07-30 05:17:44.
[view]
@@ -130,8 +130,9 @@
/*
** Send all pending files.
*/
static int send_all_pending(Blob *pOut){
+ int iRidSent = 0;
int sent = 0;
int nSent = 0;
int maxSize = db_get_int("http-msg-size", 1000000);
Stmt q;
@@ -157,14 +158,15 @@
rid, rid
);
}
#endif
- db_prepare(&q, "SELECT rid FROM pending");
+ db_prepare(&q, "SELECT rid FROM pending ORDER BY rid");
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
if( sent<maxSize ){
sent += send_file(rid, pOut);
nSent++;
+ iRidSent = rid;
}else{
char *zUuid = db_text(0,
"SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
if( zUuid ){
@@ -177,8 +179,15 @@
}
}
}
db_finalize(&q);
+
+ /* Delete the 'pending' records for all files just sent. Otherwise,
+ ** we can wind up sending some files more than once.
+ */
+ if( nSent>0 ){
+ db_multi_exec("DELETE FROM pending WHERE rid <= %d", iRidSent);
+ }
#if 0
db_multi_exec("DROP TABLE priority");
#endif