Fossil SCM

Delete records from the temporary table "pending" after sending them.

dan 2007-07-30 05:17 trunk
Commit 23c8dad306718247d2abbc88c6a255c49ba1a460
1 file changed +10 -1
+10 -1
--- src/xfer.c
+++ src/xfer.c
@@ -129,10 +129,11 @@
129129
130130
/*
131131
** Send all pending files.
132132
*/
133133
static int send_all_pending(Blob *pOut){
134
+ int iRidSent = 0;
134135
int sent = 0;
135136
int nSent = 0;
136137
int maxSize = db_get_int("http-msg-size", 1000000);
137138
Stmt q;
138139
#if 0
@@ -156,16 +157,17 @@
156157
" SELECT rid FROM delta WHERE srcid=%d",
157158
rid, rid
158159
);
159160
}
160161
#endif
161
- db_prepare(&q, "SELECT rid FROM pending");
162
+ db_prepare(&q, "SELECT rid FROM pending ORDER BY rid");
162163
while( db_step(&q)==SQLITE_ROW ){
163164
int rid = db_column_int(&q, 0);
164165
if( sent<maxSize ){
165166
sent += send_file(rid, pOut);
166167
nSent++;
168
+ iRidSent = rid;
167169
}else{
168170
char *zUuid = db_text(0,
169171
"SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
170172
if( zUuid ){
171173
if( pOut ){
@@ -177,10 +179,17 @@
177179
}
178180
}
179181
}
180182
db_finalize(&q);
181183
184
+ /* Delete the 'pending' records for all files just sent. Otherwise,
185
+ ** we can wind up sending some files more than once.
186
+ */
187
+ if( nSent>0 ){
188
+ db_multi_exec("DELETE FROM pending WHERE rid <= %d", iRidSent);
189
+ }
190
+
182191
#if 0
183192
db_multi_exec("DROP TABLE priority");
184193
#endif
185194
return nSent;
186195
}
187196
--- src/xfer.c
+++ src/xfer.c
@@ -129,10 +129,11 @@
129
130 /*
131 ** Send all pending files.
132 */
133 static int send_all_pending(Blob *pOut){
 
134 int sent = 0;
135 int nSent = 0;
136 int maxSize = db_get_int("http-msg-size", 1000000);
137 Stmt q;
138 #if 0
@@ -156,16 +157,17 @@
156 " SELECT rid FROM delta WHERE srcid=%d",
157 rid, rid
158 );
159 }
160 #endif
161 db_prepare(&q, "SELECT rid FROM pending");
162 while( db_step(&q)==SQLITE_ROW ){
163 int rid = db_column_int(&q, 0);
164 if( sent<maxSize ){
165 sent += send_file(rid, pOut);
166 nSent++;
 
167 }else{
168 char *zUuid = db_text(0,
169 "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
170 if( zUuid ){
171 if( pOut ){
@@ -177,10 +179,17 @@
177 }
178 }
179 }
180 db_finalize(&q);
181
 
 
 
 
 
 
 
182 #if 0
183 db_multi_exec("DROP TABLE priority");
184 #endif
185 return nSent;
186 }
187
--- src/xfer.c
+++ src/xfer.c
@@ -129,10 +129,11 @@
129
130 /*
131 ** Send all pending files.
132 */
133 static int send_all_pending(Blob *pOut){
134 int iRidSent = 0;
135 int sent = 0;
136 int nSent = 0;
137 int maxSize = db_get_int("http-msg-size", 1000000);
138 Stmt q;
139 #if 0
@@ -156,16 +157,17 @@
157 " SELECT rid FROM delta WHERE srcid=%d",
158 rid, rid
159 );
160 }
161 #endif
162 db_prepare(&q, "SELECT rid FROM pending ORDER BY rid");
163 while( db_step(&q)==SQLITE_ROW ){
164 int rid = db_column_int(&q, 0);
165 if( sent<maxSize ){
166 sent += send_file(rid, pOut);
167 nSent++;
168 iRidSent = rid;
169 }else{
170 char *zUuid = db_text(0,
171 "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
172 if( zUuid ){
173 if( pOut ){
@@ -177,10 +179,17 @@
179 }
180 }
181 }
182 db_finalize(&q);
183
184 /* Delete the 'pending' records for all files just sent. Otherwise,
185 ** we can wind up sending some files more than once.
186 */
187 if( nSent>0 ){
188 db_multi_exec("DELETE FROM pending WHERE rid <= %d", iRidSent);
189 }
190
191 #if 0
192 db_multi_exec("DROP TABLE priority");
193 #endif
194 return nSent;
195 }
196

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button