Fossil SCM
Delete records from the temporary table "pending" after sending them.
Commit
23c8dad306718247d2abbc88c6a255c49ba1a460
Parent
d0d4c5f5753e7c8…
1 file changed
+10
-1
+10
-1
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -129,10 +129,11 @@ | ||
| 129 | 129 | |
| 130 | 130 | /* |
| 131 | 131 | ** Send all pending files. |
| 132 | 132 | */ |
| 133 | 133 | static int send_all_pending(Blob *pOut){ |
| 134 | + int iRidSent = 0; | |
| 134 | 135 | int sent = 0; |
| 135 | 136 | int nSent = 0; |
| 136 | 137 | int maxSize = db_get_int("http-msg-size", 1000000); |
| 137 | 138 | Stmt q; |
| 138 | 139 | #if 0 |
| @@ -156,16 +157,17 @@ | ||
| 156 | 157 | " SELECT rid FROM delta WHERE srcid=%d", |
| 157 | 158 | rid, rid |
| 158 | 159 | ); |
| 159 | 160 | } |
| 160 | 161 | #endif |
| 161 | - db_prepare(&q, "SELECT rid FROM pending"); | |
| 162 | + db_prepare(&q, "SELECT rid FROM pending ORDER BY rid"); | |
| 162 | 163 | while( db_step(&q)==SQLITE_ROW ){ |
| 163 | 164 | int rid = db_column_int(&q, 0); |
| 164 | 165 | if( sent<maxSize ){ |
| 165 | 166 | sent += send_file(rid, pOut); |
| 166 | 167 | nSent++; |
| 168 | + iRidSent = rid; | |
| 167 | 169 | }else{ |
| 168 | 170 | char *zUuid = db_text(0, |
| 169 | 171 | "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid); |
| 170 | 172 | if( zUuid ){ |
| 171 | 173 | if( pOut ){ |
| @@ -177,10 +179,17 @@ | ||
| 177 | 179 | } |
| 178 | 180 | } |
| 179 | 181 | } |
| 180 | 182 | db_finalize(&q); |
| 181 | 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 | + | |
| 182 | 191 | #if 0 |
| 183 | 192 | db_multi_exec("DROP TABLE priority"); |
| 184 | 193 | #endif |
| 185 | 194 | return nSent; |
| 186 | 195 | } |
| 187 | 196 |
| --- 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 |