Fossil SCM
Only request the password one time on a push or pull.
Commit
3a25b683905d9ebab614dd094cd7fd5f045845cf
Parent
e621b6dbe310661…
8 files changed
+7
-6
+37
-3
+1
-1
+4
+3
-3
+21
-5
+9
-13
+10
-1
+7
-6
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -252,13 +252,15 @@ | ||
| 252 | 252 | if( findSrcid(rid, 0)>0 ){ |
| 253 | 253 | Blob x; |
| 254 | 254 | Stmt s; |
| 255 | 255 | content_get(rid, &x); |
| 256 | 256 | db_prepare(&s, "UPDATE blob SET content=:c WHERE rid=%d", rid); |
| 257 | + blob_compress(&x, &x); | |
| 257 | 258 | db_bind_blob(&s, ":c", &x); |
| 258 | 259 | db_exec(&s); |
| 259 | 260 | db_finalize(&s); |
| 261 | + blob_reset(&x); | |
| 260 | 262 | db_multi_exec("DELETE FROM delta WHERE rid=%d", rid); |
| 261 | 263 | } |
| 262 | 264 | } |
| 263 | 265 | |
| 264 | 266 | /* |
| @@ -284,11 +286,11 @@ | ||
| 284 | 286 | ** converted to undeltaed text. |
| 285 | 287 | */ |
| 286 | 288 | void content_deltify(int rid, int srcid, int force){ |
| 287 | 289 | int s; |
| 288 | 290 | Blob data, src, delta; |
| 289 | - static Stmt s1, s2; | |
| 291 | + Stmt s1, s2; | |
| 290 | 292 | if( srcid==rid ) return; |
| 291 | 293 | if( !force && findSrcid(rid, 0)>0 ) return; |
| 292 | 294 | s = srcid; |
| 293 | 295 | while( (s = findSrcid(s, 0))>0 ){ |
| 294 | 296 | if( s==rid ){ |
| @@ -300,20 +302,19 @@ | ||
| 300 | 302 | content_get(rid, &data); |
| 301 | 303 | blob_delta_create(&src, &data, &delta); |
| 302 | 304 | if( blob_size(&src)>=50 && blob_size(&data)>=50 && |
| 303 | 305 | blob_size(&delta) < blob_size(&data)*0.75 ){ |
| 304 | 306 | 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); | |
| 307 | + db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid); | |
| 308 | + db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, srcid); | |
| 308 | 309 | db_bind_blob(&s1, ":data", &delta); |
| 309 | - db_bind_int(&s2, ":rid", rid); | |
| 310 | - db_bind_int(&s2, ":sid", srcid); | |
| 311 | 310 | db_begin_transaction(); |
| 312 | 311 | db_exec(&s1); |
| 313 | 312 | db_exec(&s2); |
| 314 | 313 | db_end_transaction(0); |
| 314 | + db_finalize(&s1); | |
| 315 | + db_finalize(&s2); | |
| 315 | 316 | } |
| 316 | 317 | blob_reset(&src); |
| 317 | 318 | blob_reset(&data); |
| 318 | 319 | blob_reset(&delta); |
| 319 | 320 | verify_before_commit(rid); |
| 320 | 321 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -252,13 +252,15 @@ | |
| 252 | if( findSrcid(rid, 0)>0 ){ |
| 253 | Blob x; |
| 254 | Stmt s; |
| 255 | content_get(rid, &x); |
| 256 | db_prepare(&s, "UPDATE blob SET content=:c WHERE rid=%d", rid); |
| 257 | db_bind_blob(&s, ":c", &x); |
| 258 | db_exec(&s); |
| 259 | db_finalize(&s); |
| 260 | db_multi_exec("DELETE FROM delta WHERE rid=%d", rid); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /* |
| @@ -284,11 +286,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 +302,19 @@ | |
| 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 | |
| @@ -252,13 +252,15 @@ | |
| 252 | if( findSrcid(rid, 0)>0 ){ |
| 253 | Blob x; |
| 254 | Stmt s; |
| 255 | content_get(rid, &x); |
| 256 | db_prepare(&s, "UPDATE blob SET content=:c WHERE rid=%d", rid); |
| 257 | blob_compress(&x, &x); |
| 258 | db_bind_blob(&s, ":c", &x); |
| 259 | db_exec(&s); |
| 260 | db_finalize(&s); |
| 261 | blob_reset(&x); |
| 262 | db_multi_exec("DELETE FROM delta WHERE rid=%d", rid); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | /* |
| @@ -284,11 +286,11 @@ | |
| 286 | ** converted to undeltaed text. |
| 287 | */ |
| 288 | void content_deltify(int rid, int srcid, int force){ |
| 289 | int s; |
| 290 | Blob data, src, delta; |
| 291 | Stmt s1, s2; |
| 292 | if( srcid==rid ) return; |
| 293 | if( !force && findSrcid(rid, 0)>0 ) return; |
| 294 | s = srcid; |
| 295 | while( (s = findSrcid(s, 0))>0 ){ |
| 296 | if( s==rid ){ |
| @@ -300,20 +302,19 @@ | |
| 302 | content_get(rid, &data); |
| 303 | blob_delta_create(&src, &data, &delta); |
| 304 | if( blob_size(&src)>=50 && blob_size(&data)>=50 && |
| 305 | blob_size(&delta) < blob_size(&data)*0.75 ){ |
| 306 | blob_compress(&delta, &delta); |
| 307 | db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid); |
| 308 | db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, srcid); |
| 309 | db_bind_blob(&s1, ":data", &delta); |
| 310 | db_begin_transaction(); |
| 311 | db_exec(&s1); |
| 312 | db_exec(&s2); |
| 313 | db_end_transaction(0); |
| 314 | db_finalize(&s1); |
| 315 | db_finalize(&s2); |
| 316 | } |
| 317 | blob_reset(&src); |
| 318 | blob_reset(&data); |
| 319 | blob_reset(&delta); |
| 320 | verify_before_commit(rid); |
| 321 |
M
src/db.c
+37
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -538,23 +538,26 @@ | ||
| 538 | 538 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 539 | 539 | db_err("pwd too big: max %d", sizeof(zPwd)-20); |
| 540 | 540 | } |
| 541 | 541 | n = strlen(zPwd); |
| 542 | 542 | while( n>0 ){ |
| 543 | - if( access(zPwd, W_OK) ) return 0; | |
| 543 | + if( access(zPwd, W_OK) ) break; | |
| 544 | 544 | strcpy(&zPwd[n], "/_FOSSIL_"); |
| 545 | 545 | if( isValidLocalDb(zPwd) ){ |
| 546 | + /* Found a valid _FOSSIL_ file */ | |
| 546 | 547 | zPwd[n] = 0; |
| 547 | 548 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 548 | - break; | |
| 549 | + return 1; | |
| 549 | 550 | } |
| 550 | 551 | n--; |
| 551 | 552 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| 552 | 553 | while( n>0 && zPwd[n-1]=='/' ){ n--; } |
| 553 | 554 | zPwd[n] = 0; |
| 554 | 555 | } |
| 555 | - return n>0; | |
| 556 | + | |
| 557 | + /* A _FOSSIL_ file could not be found */ | |
| 558 | + return 0; | |
| 556 | 559 | } |
| 557 | 560 | |
| 558 | 561 | /* |
| 559 | 562 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 560 | 563 | ** get the name from the already open local database. |
| @@ -773,10 +776,41 @@ | ||
| 773 | 776 | return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName); |
| 774 | 777 | } |
| 775 | 778 | void db_lset_int(const char *zName, int value){ |
| 776 | 779 | db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value); |
| 777 | 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 | + | |
| 778 | 812 | |
| 779 | 813 | /* |
| 780 | 814 | ** COMMAND: open |
| 781 | 815 | ** |
| 782 | 816 | ** Create a new local repository. |
| 783 | 817 |
| --- 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 |
+1
-1
| --- src/deltacmd.c | ||
| +++ src/deltacmd.c | ||
| @@ -30,15 +30,15 @@ | ||
| 30 | 30 | ** Create a delta that describes the change from pOriginal to pTarget |
| 31 | 31 | ** and put that delta in pDelta. The pDelta blob is assumed to be |
| 32 | 32 | ** uninitialized. |
| 33 | 33 | */ |
| 34 | 34 | int blob_delta_create(Blob *pOriginal, Blob *pTarget, Blob *pDelta){ |
| 35 | - blob_zero(pDelta); | |
| 36 | 35 | const char *zOrig, *zTarg; |
| 37 | 36 | int lenOrig, lenTarg; |
| 38 | 37 | int len; |
| 39 | 38 | char *zRes; |
| 39 | + blob_zero(pDelta); | |
| 40 | 40 | zOrig = blob_buffer(pOriginal); |
| 41 | 41 | lenOrig = blob_size(pOriginal); |
| 42 | 42 | zTarg = blob_buffer(pTarget); |
| 43 | 43 | lenTarg = blob_size(pTarget); |
| 44 | 44 | blob_resize(pDelta, lenTarg+16); |
| 45 | 45 |
| --- src/deltacmd.c | |
| +++ src/deltacmd.c | |
| @@ -30,15 +30,15 @@ | |
| 30 | ** Create a delta that describes the change from pOriginal to pTarget |
| 31 | ** and put that delta in pDelta. The pDelta blob is assumed to be |
| 32 | ** uninitialized. |
| 33 | */ |
| 34 | int blob_delta_create(Blob *pOriginal, Blob *pTarget, Blob *pDelta){ |
| 35 | blob_zero(pDelta); |
| 36 | const char *zOrig, *zTarg; |
| 37 | int lenOrig, lenTarg; |
| 38 | int len; |
| 39 | char *zRes; |
| 40 | zOrig = blob_buffer(pOriginal); |
| 41 | lenOrig = blob_size(pOriginal); |
| 42 | zTarg = blob_buffer(pTarget); |
| 43 | lenTarg = blob_size(pTarget); |
| 44 | blob_resize(pDelta, lenTarg+16); |
| 45 |
| --- src/deltacmd.c | |
| +++ src/deltacmd.c | |
| @@ -30,15 +30,15 @@ | |
| 30 | ** Create a delta that describes the change from pOriginal to pTarget |
| 31 | ** and put that delta in pDelta. The pDelta blob is assumed to be |
| 32 | ** uninitialized. |
| 33 | */ |
| 34 | int blob_delta_create(Blob *pOriginal, Blob *pTarget, Blob *pDelta){ |
| 35 | const char *zOrig, *zTarg; |
| 36 | int lenOrig, lenTarg; |
| 37 | int len; |
| 38 | char *zRes; |
| 39 | blob_zero(pDelta); |
| 40 | zOrig = blob_buffer(pOriginal); |
| 41 | lenOrig = blob_size(pOriginal); |
| 42 | zTarg = blob_buffer(pTarget); |
| 43 | lenTarg = blob_size(pTarget); |
| 44 | blob_resize(pDelta, lenTarg+16); |
| 45 |
+4
| --- src/encode.c | ||
| +++ src/encode.c | ||
| @@ -182,10 +182,14 @@ | ||
| 182 | 182 | ** Remove the HTTP encodings from a string. The conversion is done |
| 183 | 183 | ** in-place. Return the length of the string after conversion. |
| 184 | 184 | */ |
| 185 | 185 | int dehttpize(char *z){ |
| 186 | 186 | int i, j; |
| 187 | + | |
| 188 | + /* Treat a null pointer as a zero-length string. */ | |
| 189 | + if( !z ) return 0; | |
| 190 | + | |
| 187 | 191 | i = j = 0; |
| 188 | 192 | while( z[i] ){ |
| 189 | 193 | switch( z[i] ){ |
| 190 | 194 | case '%': |
| 191 | 195 | if( z[i+1] && z[i+2] ){ |
| 192 | 196 |
| --- src/encode.c | |
| +++ src/encode.c | |
| @@ -182,10 +182,14 @@ | |
| 182 | ** Remove the HTTP encodings from a string. The conversion is done |
| 183 | ** in-place. Return the length of the string after conversion. |
| 184 | */ |
| 185 | int dehttpize(char *z){ |
| 186 | int i, j; |
| 187 | i = j = 0; |
| 188 | while( z[i] ){ |
| 189 | switch( z[i] ){ |
| 190 | case '%': |
| 191 | if( z[i+1] && z[i+2] ){ |
| 192 |
| --- src/encode.c | |
| +++ src/encode.c | |
| @@ -182,10 +182,14 @@ | |
| 182 | ** Remove the HTTP encodings from a string. The conversion is done |
| 183 | ** in-place. Return the length of the string after conversion. |
| 184 | */ |
| 185 | int dehttpize(char *z){ |
| 186 | int i, j; |
| 187 | |
| 188 | /* Treat a null pointer as a zero-length string. */ |
| 189 | if( !z ) return 0; |
| 190 | |
| 191 | i = j = 0; |
| 192 | while( z[i] ){ |
| 193 | switch( z[i] ){ |
| 194 | case '%': |
| 195 | if( z[i+1] && z[i+2] ){ |
| 196 |
+3
-3
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -170,16 +170,16 @@ | ||
| 170 | 170 | sha1sum_blob(&pw, &sig); |
| 171 | 171 | blob_appendf(&login, "login %s %b %b\n", g.zLogin, &nonce, &sig); |
| 172 | 172 | }else{ |
| 173 | 173 | if( g.urlPasswd==0 ){ |
| 174 | 174 | if( strcmp(g.urlUser,"anonymous")!=0 ){ |
| 175 | - char *zPrompt = mprintf("password for %s", g.urlUser); | |
| 175 | + char *zPrompt = mprintf("password for %s: ", g.urlUser); | |
| 176 | 176 | Blob x; |
| 177 | 177 | prompt_for_password(zPrompt, &x, 0); |
| 178 | 178 | free(zPrompt); |
| 179 | - blob_append(&pw, blob_buffer(&x), blob_size(&x)); | |
| 180 | - blob_reset(&x); | |
| 179 | + g.urlPasswd = blob_str(&x); | |
| 180 | + blob_append(&pw, g.urlPasswd, -1); | |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | sha1sum_blob(&pw, &sig); |
| 184 | 184 | blob_appendf(&login, "login %s %b %b\n", g.urlUser, &nonce, &sig); |
| 185 | 185 | } |
| 186 | 186 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -170,16 +170,16 @@ | |
| 170 | sha1sum_blob(&pw, &sig); |
| 171 | blob_appendf(&login, "login %s %b %b\n", g.zLogin, &nonce, &sig); |
| 172 | }else{ |
| 173 | if( g.urlPasswd==0 ){ |
| 174 | if( strcmp(g.urlUser,"anonymous")!=0 ){ |
| 175 | char *zPrompt = mprintf("password for %s", g.urlUser); |
| 176 | Blob x; |
| 177 | prompt_for_password(zPrompt, &x, 0); |
| 178 | free(zPrompt); |
| 179 | blob_append(&pw, blob_buffer(&x), blob_size(&x)); |
| 180 | blob_reset(&x); |
| 181 | } |
| 182 | } |
| 183 | sha1sum_blob(&pw, &sig); |
| 184 | blob_appendf(&login, "login %s %b %b\n", g.urlUser, &nonce, &sig); |
| 185 | } |
| 186 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -170,16 +170,16 @@ | |
| 170 | sha1sum_blob(&pw, &sig); |
| 171 | blob_appendf(&login, "login %s %b %b\n", g.zLogin, &nonce, &sig); |
| 172 | }else{ |
| 173 | if( g.urlPasswd==0 ){ |
| 174 | if( strcmp(g.urlUser,"anonymous")!=0 ){ |
| 175 | char *zPrompt = mprintf("password for %s: ", g.urlUser); |
| 176 | Blob x; |
| 177 | prompt_for_password(zPrompt, &x, 0); |
| 178 | free(zPrompt); |
| 179 | g.urlPasswd = blob_str(&x); |
| 180 | blob_append(&pw, g.urlPasswd, -1); |
| 181 | } |
| 182 | } |
| 183 | sha1sum_blob(&pw, &sig); |
| 184 | blob_appendf(&login, "login %s %b %b\n", g.urlUser, &nonce, &sig); |
| 185 | } |
| 186 |
+21
-5
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -103,13 +103,13 @@ | ||
| 103 | 103 | } |
| 104 | 104 | show_common_info(rid, "uuid:", 1); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | -#if 0 | |
| 108 | +#if 1 | |
| 109 | 109 | /* |
| 110 | -** WEB PAGE: vinfo | |
| 110 | +** WEBPAGE: vinfo | |
| 111 | 111 | ** |
| 112 | 112 | ** Return information about a version. The version number is contained |
| 113 | 113 | ** in g.zExtra. |
| 114 | 114 | */ |
| 115 | 115 | void vinfo_page(void){ |
| @@ -123,14 +123,28 @@ | ||
| 123 | 123 | if( rid==0 ){ |
| 124 | 124 | @ No such object: %h(g.argv[2]) |
| 125 | 125 | style_footer(); |
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | + db_row_to_table("SELECT " | |
| 129 | + " blob.uuid AS \"UUID\"" | |
| 130 | + ", datetime(rcvfrom.mtime) AS \"Created\"" | |
| 131 | + ", rcvfrom.uid AS \"User Id\"" | |
| 132 | + ", blob.size AS \"Size\"" | |
| 133 | + "FROM blob, rcvfrom " | |
| 134 | + "WHERE rid=%d", rid | |
| 135 | + ); | |
| 136 | + style_footer(); | |
| 137 | + return; | |
| 138 | + | |
| 128 | 139 | db_prepare(&q, |
| 129 | - "SELECT uuid, datetime(mtime,'unixepoch'), datetime(ctime,'unixepoch')," | |
| 130 | - " uid, size, cksum, branch, comment, type" | |
| 131 | - " FROM record WHERE rid=%d", rid | |
| 140 | + "SELECT " | |
| 141 | + "uuid, " /* 0 */ | |
| 142 | + "datetime(mtime,'unixepoch')," /* 1 */ | |
| 143 | + "datetime(ctime,'unixepoch')," /* 2 */ | |
| 144 | + "uid, size, cksum, branch, comment, type" /* 3..8 */ | |
| 145 | + "FROM record WHERE rid=%d", rid | |
| 132 | 146 | ); |
| 133 | 147 | if( db_step(&q)==SQLITE_ROW ){ |
| 134 | 148 | const char *z; |
| 135 | 149 | const char *zSignedBy = db_text("unknown", |
| 136 | 150 | "SELECT login FROM repuser WHERE uid=%d", |
| @@ -256,11 +270,13 @@ | ||
| 256 | 270 | } |
| 257 | 271 | db_finalize(&q); |
| 258 | 272 | } |
| 259 | 273 | style_footer(); |
| 260 | 274 | } |
| 275 | +#endif | |
| 261 | 276 | |
| 277 | +#if 0 | |
| 262 | 278 | /* |
| 263 | 279 | ** WEB PAGE: diff |
| 264 | 280 | ** |
| 265 | 281 | ** Display the difference between two files determined by the v1 and v2 |
| 266 | 282 | ** query parameters. If only v2 is given compute v1 as the parent of v2. |
| 267 | 283 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -103,13 +103,13 @@ | |
| 103 | } |
| 104 | show_common_info(rid, "uuid:", 1); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | #if 0 |
| 109 | /* |
| 110 | ** WEB PAGE: vinfo |
| 111 | ** |
| 112 | ** Return information about a version. The version number is contained |
| 113 | ** in g.zExtra. |
| 114 | */ |
| 115 | void vinfo_page(void){ |
| @@ -123,14 +123,28 @@ | |
| 123 | if( rid==0 ){ |
| 124 | @ No such object: %h(g.argv[2]) |
| 125 | style_footer(); |
| 126 | return; |
| 127 | } |
| 128 | db_prepare(&q, |
| 129 | "SELECT uuid, datetime(mtime,'unixepoch'), datetime(ctime,'unixepoch')," |
| 130 | " uid, size, cksum, branch, comment, type" |
| 131 | " FROM record WHERE rid=%d", rid |
| 132 | ); |
| 133 | if( db_step(&q)==SQLITE_ROW ){ |
| 134 | const char *z; |
| 135 | const char *zSignedBy = db_text("unknown", |
| 136 | "SELECT login FROM repuser WHERE uid=%d", |
| @@ -256,11 +270,13 @@ | |
| 256 | } |
| 257 | db_finalize(&q); |
| 258 | } |
| 259 | style_footer(); |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | ** WEB PAGE: diff |
| 264 | ** |
| 265 | ** Display the difference between two files determined by the v1 and v2 |
| 266 | ** query parameters. If only v2 is given compute v1 as the parent of v2. |
| 267 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -103,13 +103,13 @@ | |
| 103 | } |
| 104 | show_common_info(rid, "uuid:", 1); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | #if 1 |
| 109 | /* |
| 110 | ** WEBPAGE: vinfo |
| 111 | ** |
| 112 | ** Return information about a version. The version number is contained |
| 113 | ** in g.zExtra. |
| 114 | */ |
| 115 | void vinfo_page(void){ |
| @@ -123,14 +123,28 @@ | |
| 123 | if( rid==0 ){ |
| 124 | @ No such object: %h(g.argv[2]) |
| 125 | style_footer(); |
| 126 | return; |
| 127 | } |
| 128 | db_row_to_table("SELECT " |
| 129 | " blob.uuid AS \"UUID\"" |
| 130 | ", datetime(rcvfrom.mtime) AS \"Created\"" |
| 131 | ", rcvfrom.uid AS \"User Id\"" |
| 132 | ", blob.size AS \"Size\"" |
| 133 | "FROM blob, rcvfrom " |
| 134 | "WHERE rid=%d", rid |
| 135 | ); |
| 136 | style_footer(); |
| 137 | return; |
| 138 | |
| 139 | db_prepare(&q, |
| 140 | "SELECT " |
| 141 | "uuid, " /* 0 */ |
| 142 | "datetime(mtime,'unixepoch')," /* 1 */ |
| 143 | "datetime(ctime,'unixepoch')," /* 2 */ |
| 144 | "uid, size, cksum, branch, comment, type" /* 3..8 */ |
| 145 | "FROM record WHERE rid=%d", rid |
| 146 | ); |
| 147 | if( db_step(&q)==SQLITE_ROW ){ |
| 148 | const char *z; |
| 149 | const char *zSignedBy = db_text("unknown", |
| 150 | "SELECT login FROM repuser WHERE uid=%d", |
| @@ -256,11 +270,13 @@ | |
| 270 | } |
| 271 | db_finalize(&q); |
| 272 | } |
| 273 | style_footer(); |
| 274 | } |
| 275 | #endif |
| 276 | |
| 277 | #if 0 |
| 278 | /* |
| 279 | ** WEB PAGE: diff |
| 280 | ** |
| 281 | ** Display the difference between two files determined by the v1 and v2 |
| 282 | ** query parameters. If only v2 is given compute v1 as the parent of v2. |
| 283 |
+9
-13
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -203,23 +203,19 @@ | ||
| 203 | 203 | g.isAnon = 0; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /* Check the login cookie to see if it matches a known valid user. |
| 207 | 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 | - } | |
| 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 | + ); | |
| 221 | 217 | } |
| 222 | 218 | |
| 223 | 219 | if( uid==0 ){ |
| 224 | 220 | g.isAnon = 1; |
| 225 | 221 | g.zLogin = ""; |
| 226 | 222 |
| --- 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 @@ | ||
| 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 |