Fossil SCM

Merge in clone and sync changes. Fix a bug in undelta.

anonymous 2007-07-30 16:31 trunk merge
Commit e3c529c2f066a72002964c1ae5d3fe5fabd7ecf0
+5 -5
--- src/content.c
+++ src/content.c
@@ -284,11 +284,11 @@
284284
** converted to undeltaed text.
285285
*/
286286
void content_deltify(int rid, int srcid, int force){
287287
int s;
288288
Blob data, src, delta;
289
- static Stmt s1, s2;
289
+ Stmt s1, s2;
290290
if( srcid==rid ) return;
291291
if( !force && findSrcid(rid, 0)>0 ) return;
292292
s = srcid;
293293
while( (s = findSrcid(s, 0))>0 ){
294294
if( s==rid ){
@@ -300,20 +300,20 @@
300300
content_get(rid, &data);
301301
blob_delta_create(&src, &data, &delta);
302302
if( blob_size(&src)>=50 && blob_size(&data)>=50 &&
303303
blob_size(&delta) < blob_size(&data)*0.75 ){
304304
blob_compress(&delta, &delta);
305
- db_static_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=:rid");
306
- db_static_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(:rid,:sid)");
307
- db_bind_int(&s1, ":rid", rid);
305
+ db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
306
+ db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,:sid)", rid);
308307
db_bind_blob(&s1, ":data", &delta);
309
- db_bind_int(&s2, ":rid", rid);
310308
db_bind_int(&s2, ":sid", srcid);
311309
db_begin_transaction();
312310
db_exec(&s1);
313311
db_exec(&s2);
314312
db_end_transaction(0);
313
+ db_finalize(&s1);
314
+ db_finalize(&s2);
315315
}
316316
blob_reset(&src);
317317
blob_reset(&data);
318318
blob_reset(&delta);
319319
verify_before_commit(rid);
320320
--- src/content.c
+++ src/content.c
@@ -284,11 +284,11 @@
284 ** converted to undeltaed text.
285 */
286 void content_deltify(int rid, int srcid, int force){
287 int s;
288 Blob data, src, delta;
289 static Stmt s1, s2;
290 if( srcid==rid ) return;
291 if( !force && findSrcid(rid, 0)>0 ) return;
292 s = srcid;
293 while( (s = findSrcid(s, 0))>0 ){
294 if( s==rid ){
@@ -300,20 +300,20 @@
300 content_get(rid, &data);
301 blob_delta_create(&src, &data, &delta);
302 if( blob_size(&src)>=50 && blob_size(&data)>=50 &&
303 blob_size(&delta) < blob_size(&data)*0.75 ){
304 blob_compress(&delta, &delta);
305 db_static_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=:rid");
306 db_static_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(:rid,:sid)");
307 db_bind_int(&s1, ":rid", rid);
308 db_bind_blob(&s1, ":data", &delta);
309 db_bind_int(&s2, ":rid", rid);
310 db_bind_int(&s2, ":sid", srcid);
311 db_begin_transaction();
312 db_exec(&s1);
313 db_exec(&s2);
314 db_end_transaction(0);
 
 
315 }
316 blob_reset(&src);
317 blob_reset(&data);
318 blob_reset(&delta);
319 verify_before_commit(rid);
320
--- src/content.c
+++ src/content.c
@@ -284,11 +284,11 @@
284 ** converted to undeltaed text.
285 */
286 void content_deltify(int rid, int srcid, int force){
287 int s;
288 Blob data, src, delta;
289 Stmt s1, s2;
290 if( srcid==rid ) return;
291 if( !force && findSrcid(rid, 0)>0 ) return;
292 s = srcid;
293 while( (s = findSrcid(s, 0))>0 ){
294 if( s==rid ){
@@ -300,20 +300,20 @@
300 content_get(rid, &data);
301 blob_delta_create(&src, &data, &delta);
302 if( blob_size(&src)>=50 && blob_size(&data)>=50 &&
303 blob_size(&delta) < blob_size(&data)*0.75 ){
304 blob_compress(&delta, &delta);
305 db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
306 db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,:sid)", rid);
 
307 db_bind_blob(&s1, ":data", &delta);
 
308 db_bind_int(&s2, ":sid", srcid);
309 db_begin_transaction();
310 db_exec(&s1);
311 db_exec(&s2);
312 db_end_transaction(0);
313 db_finalize(&s1);
314 db_finalize(&s2);
315 }
316 blob_reset(&src);
317 blob_reset(&data);
318 blob_reset(&delta);
319 verify_before_commit(rid);
320
+5 -5
--- src/content.c
+++ src/content.c
@@ -284,11 +284,11 @@
284284
** converted to undeltaed text.
285285
*/
286286
void content_deltify(int rid, int srcid, int force){
287287
int s;
288288
Blob data, src, delta;
289
- static Stmt s1, s2;
289
+ Stmt s1, s2;
290290
if( srcid==rid ) return;
291291
if( !force && findSrcid(rid, 0)>0 ) return;
292292
s = srcid;
293293
while( (s = findSrcid(s, 0))>0 ){
294294
if( s==rid ){
@@ -300,20 +300,20 @@
300300
content_get(rid, &data);
301301
blob_delta_create(&src, &data, &delta);
302302
if( blob_size(&src)>=50 && blob_size(&data)>=50 &&
303303
blob_size(&delta) < blob_size(&data)*0.75 ){
304304
blob_compress(&delta, &delta);
305
- db_static_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=:rid");
306
- db_static_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(:rid,:sid)");
307
- db_bind_int(&s1, ":rid", rid);
305
+ db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
306
+ db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,:sid)", rid);
308307
db_bind_blob(&s1, ":data", &delta);
309
- db_bind_int(&s2, ":rid", rid);
310308
db_bind_int(&s2, ":sid", srcid);
311309
db_begin_transaction();
312310
db_exec(&s1);
313311
db_exec(&s2);
314312
db_end_transaction(0);
313
+ db_finalize(&s1);
314
+ db_finalize(&s2);
315315
}
316316
blob_reset(&src);
317317
blob_reset(&data);
318318
blob_reset(&delta);
319319
verify_before_commit(rid);
320320
--- src/content.c
+++ src/content.c
@@ -284,11 +284,11 @@
284 ** converted to undeltaed text.
285 */
286 void content_deltify(int rid, int srcid, int force){
287 int s;
288 Blob data, src, delta;
289 static Stmt s1, s2;
290 if( srcid==rid ) return;
291 if( !force && findSrcid(rid, 0)>0 ) return;
292 s = srcid;
293 while( (s = findSrcid(s, 0))>0 ){
294 if( s==rid ){
@@ -300,20 +300,20 @@
300 content_get(rid, &data);
301 blob_delta_create(&src, &data, &delta);
302 if( blob_size(&src)>=50 && blob_size(&data)>=50 &&
303 blob_size(&delta) < blob_size(&data)*0.75 ){
304 blob_compress(&delta, &delta);
305 db_static_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=:rid");
306 db_static_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(:rid,:sid)");
307 db_bind_int(&s1, ":rid", rid);
308 db_bind_blob(&s1, ":data", &delta);
309 db_bind_int(&s2, ":rid", rid);
310 db_bind_int(&s2, ":sid", srcid);
311 db_begin_transaction();
312 db_exec(&s1);
313 db_exec(&s2);
314 db_end_transaction(0);
 
 
315 }
316 blob_reset(&src);
317 blob_reset(&data);
318 blob_reset(&delta);
319 verify_before_commit(rid);
320
--- src/content.c
+++ src/content.c
@@ -284,11 +284,11 @@
284 ** converted to undeltaed text.
285 */
286 void content_deltify(int rid, int srcid, int force){
287 int s;
288 Blob data, src, delta;
289 Stmt s1, s2;
290 if( srcid==rid ) return;
291 if( !force && findSrcid(rid, 0)>0 ) return;
292 s = srcid;
293 while( (s = findSrcid(s, 0))>0 ){
294 if( s==rid ){
@@ -300,20 +300,20 @@
300 content_get(rid, &data);
301 blob_delta_create(&src, &data, &delta);
302 if( blob_size(&src)>=50 && blob_size(&data)>=50 &&
303 blob_size(&delta) < blob_size(&data)*0.75 ){
304 blob_compress(&delta, &delta);
305 db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
306 db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,:sid)", rid);
 
307 db_bind_blob(&s1, ":data", &delta);
 
308 db_bind_int(&s2, ":sid", srcid);
309 db_begin_transaction();
310 db_exec(&s1);
311 db_exec(&s2);
312 db_end_transaction(0);
313 db_finalize(&s1);
314 db_finalize(&s2);
315 }
316 blob_reset(&src);
317 blob_reset(&data);
318 blob_reset(&delta);
319 verify_before_commit(rid);
320
+37 -3
--- src/db.c
+++ src/db.c
@@ -538,23 +538,26 @@
538538
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
539539
db_err("pwd too big: max %d", sizeof(zPwd)-20);
540540
}
541541
n = strlen(zPwd);
542542
while( n>0 ){
543
- if( access(zPwd, W_OK) ) return 0;
543
+ if( access(zPwd, W_OK) ) break;
544544
strcpy(&zPwd[n], "/_FOSSIL_");
545545
if( isValidLocalDb(zPwd) ){
546
+ /* Found a valid _FOSSIL_ file */
546547
zPwd[n] = 0;
547548
g.zLocalRoot = mprintf("%s/", zPwd);
548
- break;
549
+ return 1;
549550
}
550551
n--;
551552
while( n>0 && zPwd[n]!='/' ){ n--; }
552553
while( n>0 && zPwd[n-1]=='/' ){ n--; }
553554
zPwd[n] = 0;
554555
}
555
- return n>0;
556
+
557
+ /* A _FOSSIL_ file could not be found */
558
+ return 0;
556559
}
557560
558561
/*
559562
** Open the repository database given by zDbName. If zDbName==NULL then
560563
** get the name from the already open local database.
@@ -773,10 +776,41 @@
773776
return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
774777
}
775778
void db_lset_int(const char *zName, int value){
776779
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
777780
}
781
+
782
+int db_row_to_table(const char *zFormat, ...){
783
+ Stmt q;
784
+ va_list ap;
785
+ int rc;
786
+
787
+ va_start(ap, zFormat);
788
+ rc = db_vprepare(&q, zFormat, ap);
789
+ va_end(ap);
790
+ if( rc!=SQLITE_OK ){
791
+ return rc;
792
+ }
793
+
794
+ @ <table border="0" cellpadding="0" cellspacing="0">
795
+ if( db_step(&q)==SQLITE_ROW ){
796
+ int ii;
797
+ for(ii=0; ii<sqlite3_column_count(q.pStmt); ii++){
798
+ char *zCol = htmlize(sqlite3_column_name(q.pStmt, ii), -1);
799
+ char *zVal = htmlize(sqlite3_column_text(q.pStmt, ii), -1);
800
+
801
+ @ <tr><td align=right>%s(zCol):<td width=10><td>%s(zVal)
802
+
803
+ free(zVal);
804
+ free(zCol);
805
+ }
806
+ }
807
+ @ </table>
808
+
809
+ return db_finalize(&q);
810
+}
811
+
778812
779813
/*
780814
** COMMAND: open
781815
**
782816
** Create a new local repository.
783817
--- src/db.c
+++ src/db.c
@@ -538,23 +538,26 @@
538 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
539 db_err("pwd too big: max %d", sizeof(zPwd)-20);
540 }
541 n = strlen(zPwd);
542 while( n>0 ){
543 if( access(zPwd, W_OK) ) return 0;
544 strcpy(&zPwd[n], "/_FOSSIL_");
545 if( isValidLocalDb(zPwd) ){
 
546 zPwd[n] = 0;
547 g.zLocalRoot = mprintf("%s/", zPwd);
548 break;
549 }
550 n--;
551 while( n>0 && zPwd[n]!='/' ){ n--; }
552 while( n>0 && zPwd[n-1]=='/' ){ n--; }
553 zPwd[n] = 0;
554 }
555 return n>0;
 
 
556 }
557
558 /*
559 ** Open the repository database given by zDbName. If zDbName==NULL then
560 ** get the name from the already open local database.
@@ -773,10 +776,41 @@
773 return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
774 }
775 void db_lset_int(const char *zName, int value){
776 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
777 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
779 /*
780 ** COMMAND: open
781 **
782 ** Create a new local repository.
783
--- src/db.c
+++ src/db.c
@@ -538,23 +538,26 @@
538 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
539 db_err("pwd too big: max %d", sizeof(zPwd)-20);
540 }
541 n = strlen(zPwd);
542 while( n>0 ){
543 if( access(zPwd, W_OK) ) break;
544 strcpy(&zPwd[n], "/_FOSSIL_");
545 if( isValidLocalDb(zPwd) ){
546 /* Found a valid _FOSSIL_ file */
547 zPwd[n] = 0;
548 g.zLocalRoot = mprintf("%s/", zPwd);
549 return 1;
550 }
551 n--;
552 while( n>0 && zPwd[n]!='/' ){ n--; }
553 while( n>0 && zPwd[n-1]=='/' ){ n--; }
554 zPwd[n] = 0;
555 }
556
557 /* A _FOSSIL_ file could not be found */
558 return 0;
559 }
560
561 /*
562 ** Open the repository database given by zDbName. If zDbName==NULL then
563 ** get the name from the already open local database.
@@ -773,10 +776,41 @@
776 return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
777 }
778 void db_lset_int(const char *zName, int value){
779 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
780 }
781
782 int db_row_to_table(const char *zFormat, ...){
783 Stmt q;
784 va_list ap;
785 int rc;
786
787 va_start(ap, zFormat);
788 rc = db_vprepare(&q, zFormat, ap);
789 va_end(ap);
790 if( rc!=SQLITE_OK ){
791 return rc;
792 }
793
794 @ <table border="0" cellpadding="0" cellspacing="0">
795 if( db_step(&q)==SQLITE_ROW ){
796 int ii;
797 for(ii=0; ii<sqlite3_column_count(q.pStmt); ii++){
798 char *zCol = htmlize(sqlite3_column_name(q.pStmt, ii), -1);
799 char *zVal = htmlize(sqlite3_column_text(q.pStmt, ii), -1);
800
801 @ <tr><td align=right>%s(zCol):<td width=10><td>%s(zVal)
802
803 free(zVal);
804 free(zCol);
805 }
806 }
807 @ </table>
808
809 return db_finalize(&q);
810 }
811
812
813 /*
814 ** COMMAND: open
815 **
816 ** Create a new local repository.
817
+37 -3
--- src/db.c
+++ src/db.c
@@ -538,23 +538,26 @@
538538
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
539539
db_err("pwd too big: max %d", sizeof(zPwd)-20);
540540
}
541541
n = strlen(zPwd);
542542
while( n>0 ){
543
- if( access(zPwd, W_OK) ) return 0;
543
+ if( access(zPwd, W_OK) ) break;
544544
strcpy(&zPwd[n], "/_FOSSIL_");
545545
if( isValidLocalDb(zPwd) ){
546
+ /* Found a valid _FOSSIL_ file */
546547
zPwd[n] = 0;
547548
g.zLocalRoot = mprintf("%s/", zPwd);
548
- break;
549
+ return 1;
549550
}
550551
n--;
551552
while( n>0 && zPwd[n]!='/' ){ n--; }
552553
while( n>0 && zPwd[n-1]=='/' ){ n--; }
553554
zPwd[n] = 0;
554555
}
555
- return n>0;
556
+
557
+ /* A _FOSSIL_ file could not be found */
558
+ return 0;
556559
}
557560
558561
/*
559562
** Open the repository database given by zDbName. If zDbName==NULL then
560563
** get the name from the already open local database.
@@ -773,10 +776,41 @@
773776
return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
774777
}
775778
void db_lset_int(const char *zName, int value){
776779
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
777780
}
781
+
782
+int db_row_to_table(const char *zFormat, ...){
783
+ Stmt q;
784
+ va_list ap;
785
+ int rc;
786
+
787
+ va_start(ap, zFormat);
788
+ rc = db_vprepare(&q, zFormat, ap);
789
+ va_end(ap);
790
+ if( rc!=SQLITE_OK ){
791
+ return rc;
792
+ }
793
+
794
+ @ <table border="0" cellpadding="0" cellspacing="0">
795
+ if( db_step(&q)==SQLITE_ROW ){
796
+ int ii;
797
+ for(ii=0; ii<sqlite3_column_count(q.pStmt); ii++){
798
+ char *zCol = htmlize(sqlite3_column_name(q.pStmt, ii), -1);
799
+ char *zVal = htmlize(sqlite3_column_text(q.pStmt, ii), -1);
800
+
801
+ @ <tr><td align=right>%s(zCol):<td width=10><td>%s(zVal)
802
+
803
+ free(zVal);
804
+ free(zCol);
805
+ }
806
+ }
807
+ @ </table>
808
+
809
+ return db_finalize(&q);
810
+}
811
+
778812
779813
/*
780814
** COMMAND: open
781815
**
782816
** Create a new local repository.
783817
--- src/db.c
+++ src/db.c
@@ -538,23 +538,26 @@
538 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
539 db_err("pwd too big: max %d", sizeof(zPwd)-20);
540 }
541 n = strlen(zPwd);
542 while( n>0 ){
543 if( access(zPwd, W_OK) ) return 0;
544 strcpy(&zPwd[n], "/_FOSSIL_");
545 if( isValidLocalDb(zPwd) ){
 
546 zPwd[n] = 0;
547 g.zLocalRoot = mprintf("%s/", zPwd);
548 break;
549 }
550 n--;
551 while( n>0 && zPwd[n]!='/' ){ n--; }
552 while( n>0 && zPwd[n-1]=='/' ){ n--; }
553 zPwd[n] = 0;
554 }
555 return n>0;
 
 
556 }
557
558 /*
559 ** Open the repository database given by zDbName. If zDbName==NULL then
560 ** get the name from the already open local database.
@@ -773,10 +776,41 @@
773 return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
774 }
775 void db_lset_int(const char *zName, int value){
776 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
777 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
779 /*
780 ** COMMAND: open
781 **
782 ** Create a new local repository.
783
--- src/db.c
+++ src/db.c
@@ -538,23 +538,26 @@
538 if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
539 db_err("pwd too big: max %d", sizeof(zPwd)-20);
540 }
541 n = strlen(zPwd);
542 while( n>0 ){
543 if( access(zPwd, W_OK) ) break;
544 strcpy(&zPwd[n], "/_FOSSIL_");
545 if( isValidLocalDb(zPwd) ){
546 /* Found a valid _FOSSIL_ file */
547 zPwd[n] = 0;
548 g.zLocalRoot = mprintf("%s/", zPwd);
549 return 1;
550 }
551 n--;
552 while( n>0 && zPwd[n]!='/' ){ n--; }
553 while( n>0 && zPwd[n-1]=='/' ){ n--; }
554 zPwd[n] = 0;
555 }
556
557 /* A _FOSSIL_ file could not be found */
558 return 0;
559 }
560
561 /*
562 ** Open the repository database given by zDbName. If zDbName==NULL then
563 ** get the name from the already open local database.
@@ -773,10 +776,41 @@
776 return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
777 }
778 void db_lset_int(const char *zName, int value){
779 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
780 }
781
782 int db_row_to_table(const char *zFormat, ...){
783 Stmt q;
784 va_list ap;
785 int rc;
786
787 va_start(ap, zFormat);
788 rc = db_vprepare(&q, zFormat, ap);
789 va_end(ap);
790 if( rc!=SQLITE_OK ){
791 return rc;
792 }
793
794 @ <table border="0" cellpadding="0" cellspacing="0">
795 if( db_step(&q)==SQLITE_ROW ){
796 int ii;
797 for(ii=0; ii<sqlite3_column_count(q.pStmt); ii++){
798 char *zCol = htmlize(sqlite3_column_name(q.pStmt, ii), -1);
799 char *zVal = htmlize(sqlite3_column_text(q.pStmt, ii), -1);
800
801 @ <tr><td align=right>%s(zCol):<td width=10><td>%s(zVal)
802
803 free(zVal);
804 free(zCol);
805 }
806 }
807 @ </table>
808
809 return db_finalize(&q);
810 }
811
812
813 /*
814 ** COMMAND: open
815 **
816 ** Create a new local repository.
817
+9 -13
--- src/login.c
+++ src/login.c
@@ -203,23 +203,19 @@
203203
g.isAnon = 0;
204204
}
205205
206206
/* Check the login cookie to see if it matches a known valid user.
207207
*/
208
- if( uid==0 ){
209
- if( (zCookie = P(login_cookie_name()))!=0 ){
210
- uid = db_int(0,
211
- "SELECT uid FROM user"
212
- " WHERE uid=%d"
213
- " AND cookie=%Q"
214
- " AND ipaddr=%Q"
215
- " AND cexpire>julianday('now')",
216
- atoi(zCookie), zCookie, zRemoteAddr
217
- );
218
- }else{
219
- uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'");
220
- }
208
+ if( uid==0 && (zCookie = P(login_cookie_name()))!=0 ){
209
+ uid = db_int(0,
210
+ "SELECT 1 FROM user"
211
+ " WHERE uid=%d"
212
+ " AND cookie=%Q"
213
+ " AND ipaddr=%Q"
214
+ " AND cexpire>julianday('now')",
215
+ atoi(zCookie), zCookie, zRemoteAddr
216
+ );
221217
}
222218
223219
if( uid==0 ){
224220
g.isAnon = 1;
225221
g.zLogin = "";
226222
--- src/login.c
+++ src/login.c
@@ -203,23 +203,19 @@
203 g.isAnon = 0;
204 }
205
206 /* Check the login cookie to see if it matches a known valid user.
207 */
208 if( uid==0 ){
209 if( (zCookie = P(login_cookie_name()))!=0 ){
210 uid = db_int(0,
211 "SELECT uid FROM user"
212 " WHERE uid=%d"
213 " AND cookie=%Q"
214 " AND ipaddr=%Q"
215 " AND cexpire>julianday('now')",
216 atoi(zCookie), zCookie, zRemoteAddr
217 );
218 }else{
219 uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'");
220 }
221 }
222
223 if( uid==0 ){
224 g.isAnon = 1;
225 g.zLogin = "";
226
--- src/login.c
+++ src/login.c
@@ -203,23 +203,19 @@
203 g.isAnon = 0;
204 }
205
206 /* Check the login cookie to see if it matches a known valid user.
207 */
208 if( uid==0 && (zCookie = P(login_cookie_name()))!=0 ){
209 uid = db_int(0,
210 "SELECT 1 FROM user"
211 " WHERE uid=%d"
212 " AND cookie=%Q"
213 " AND ipaddr=%Q"
214 " AND cexpire>julianday('now')",
215 atoi(zCookie), zCookie, zRemoteAddr
216 );
 
 
 
 
217 }
218
219 if( uid==0 ){
220 g.isAnon = 1;
221 g.zLogin = "";
222
+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
+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