Overview
SHA1 Hash: | 3a25b683905d9ebab614dd094cd7fd5f045845cf |
---|---|
Date: | 2007-07-30 16:35:16 |
User: | drh |
Comment: | Only request the password one time on a push or pull. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/content.c from [fa624bb975] to [f226d0adbd].
@@ -252,13 +252,15 @@ if( findSrcid(rid, 0)>0 ){ Blob x; Stmt s; content_get(rid, &x); db_prepare(&s, "UPDATE blob SET content=:c WHERE rid=%d", rid); + blob_compress(&x, &x); db_bind_blob(&s, ":c", &x); db_exec(&s); db_finalize(&s); + blob_reset(&x); db_multi_exec("DELETE FROM delta WHERE rid=%d", rid); } } /* @@ -284,11 +286,11 @@ ** converted to undeltaed text. */ void content_deltify(int rid, int srcid, int force){ int s; Blob data, src, delta; - static Stmt s1, s2; + Stmt s1, s2; if( srcid==rid ) return; if( !force && findSrcid(rid, 0)>0 ) return; s = srcid; while( (s = findSrcid(s, 0))>0 ){ if( s==rid ){ @@ -300,20 +302,19 @@ content_get(rid, &data); blob_delta_create(&src, &data, &delta); if( blob_size(&src)>=50 && blob_size(&data)>=50 && blob_size(&delta) < blob_size(&data)*0.75 ){ blob_compress(&delta, &delta); - db_static_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=:rid"); - db_static_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(:rid,:sid)"); - db_bind_int(&s1, ":rid", rid); - db_bind_blob(&s1, ":data", &delta); - db_bind_int(&s2, ":rid", rid); - db_bind_int(&s2, ":sid", srcid); + db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid); + db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, srcid); + db_bind_blob(&s1, ":data", &delta); db_begin_transaction(); db_exec(&s1); db_exec(&s2); db_end_transaction(0); + db_finalize(&s1); + db_finalize(&s2); } blob_reset(&src); blob_reset(&data); blob_reset(&delta); verify_before_commit(rid);
Modified src/db.c from [73fc8fe15d] to [44658ef357].
@@ -538,23 +538,26 @@ if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ db_err("pwd too big: max %d", sizeof(zPwd)-20); } n = strlen(zPwd); while( n>0 ){ - if( access(zPwd, W_OK) ) return 0; + if( access(zPwd, W_OK) ) break; strcpy(&zPwd[n], "/_FOSSIL_"); if( isValidLocalDb(zPwd) ){ + /* Found a valid _FOSSIL_ file */ zPwd[n] = 0; g.zLocalRoot = mprintf("%s/", zPwd); - break; + return 1; } n--; while( n>0 && zPwd[n]!='/' ){ n--; } while( n>0 && zPwd[n-1]=='/' ){ n--; } zPwd[n] = 0; } - return n>0; + + /* A _FOSSIL_ file could not be found */ + return 0; } /* ** Open the repository database given by zDbName. If zDbName==NULL then ** get the name from the already open local database. @@ -773,10 +776,41 @@ return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName); } void db_lset_int(const char *zName, int value){ db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value); } + +int db_row_to_table(const char *zFormat, ...){ + Stmt q; + va_list ap; + int rc; + + va_start(ap, zFormat); + rc = db_vprepare(&q, zFormat, ap); + va_end(ap); + if( rc!=SQLITE_OK ){ + return rc; + } + + @ <table border="0" cellpadding="0" cellspacing="0"> + if( db_step(&q)==SQLITE_ROW ){ + int ii; + for(ii=0; ii<sqlite3_column_count(q.pStmt); ii++){ + char *zCol = htmlize(sqlite3_column_name(q.pStmt, ii), -1); + char *zVal = htmlize(sqlite3_column_text(q.pStmt, ii), -1); + + @ <tr><td align=right>%s(zCol):<td width=10><td>%s(zVal) + + free(zVal); + free(zCol); + } + } + @ </table> + + return db_finalize(&q); +} + /* ** COMMAND: open ** ** Create a new local repository.
Modified src/deltacmd.c from [a84ef9f6ad] to [e730b77c18].
@@ -30,15 +30,15 @@ ** Create a delta that describes the change from pOriginal to pTarget ** and put that delta in pDelta. The pDelta blob is assumed to be ** uninitialized. */ int blob_delta_create(Blob *pOriginal, Blob *pTarget, Blob *pDelta){ - blob_zero(pDelta); const char *zOrig, *zTarg; int lenOrig, lenTarg; int len; char *zRes; + blob_zero(pDelta); zOrig = blob_buffer(pOriginal); lenOrig = blob_size(pOriginal); zTarg = blob_buffer(pTarget); lenTarg = blob_size(pTarget); blob_resize(pDelta, lenTarg+16);
Modified src/encode.c from [af8a8318d1] to [6c31150f72].
@@ -182,10 +182,14 @@ ** Remove the HTTP encodings from a string. The conversion is done ** in-place. Return the length of the string after conversion. */ int dehttpize(char *z){ int i, j; + + /* Treat a null pointer as a zero-length string. */ + if( !z ) return 0; + i = j = 0; while( z[i] ){ switch( z[i] ){ case '%': if( z[i+1] && z[i+2] ){
Modified src/http.c from [a8e6ad7f13] to [93a1f90e4d].
@@ -170,16 +170,16 @@ sha1sum_blob(&pw, &sig); blob_appendf(&login, "login %s %b %b\n", g.zLogin, &nonce, &sig); }else{ if( g.urlPasswd==0 ){ if( strcmp(g.urlUser,"anonymous")!=0 ){ - char *zPrompt = mprintf("password for %s", g.urlUser); + char *zPrompt = mprintf("password for %s: ", g.urlUser); Blob x; prompt_for_password(zPrompt, &x, 0); free(zPrompt); - blob_append(&pw, blob_buffer(&x), blob_size(&x)); - blob_reset(&x); + g.urlPasswd = blob_str(&x); + blob_append(&pw, g.urlPasswd, -1); } } sha1sum_blob(&pw, &sig); blob_appendf(&login, "login %s %b %b\n", g.urlUser, &nonce, &sig); }
Modified src/info.c from [cb6cea5bd7] to [199807a9fd].
@@ -103,13 +103,13 @@ } show_common_info(rid, "uuid:", 1); } } -#if 0 +#if 1 /* -** WEB PAGE: vinfo +** WEBPAGE: vinfo ** ** Return information about a version. The version number is contained ** in g.zExtra. */ void vinfo_page(void){ @@ -123,14 +123,28 @@ if( rid==0 ){ @ No such object: %h(g.argv[2]) style_footer(); return; } + db_row_to_table("SELECT " + " blob.uuid AS \"UUID\"" + ", datetime(rcvfrom.mtime) AS \"Created\"" + ", rcvfrom.uid AS \"User Id\"" + ", blob.size AS \"Size\"" + "FROM blob, rcvfrom " + "WHERE rid=%d", rid + ); + style_footer(); + return; + db_prepare(&q, - "SELECT uuid, datetime(mtime,'unixepoch'), datetime(ctime,'unixepoch')," - " uid, size, cksum, branch, comment, type" - " FROM record WHERE rid=%d", rid + "SELECT " + "uuid, " /* 0 */ + "datetime(mtime,'unixepoch')," /* 1 */ + "datetime(ctime,'unixepoch')," /* 2 */ + "uid, size, cksum, branch, comment, type" /* 3..8 */ + "FROM record WHERE rid=%d", rid ); if( db_step(&q)==SQLITE_ROW ){ const char *z; const char *zSignedBy = db_text("unknown", "SELECT login FROM repuser WHERE uid=%d", @@ -256,11 +270,13 @@ } db_finalize(&q); } style_footer(); } +#endif +#if 0 /* ** WEB PAGE: diff ** ** Display the difference between two files determined by the v1 and v2 ** query parameters. If only v2 is given compute v1 as the parent of v2.
Modified src/login.c from [769bfdbb7f] to [c801bf1f9b].
@@ -203,23 +203,19 @@ g.isAnon = 0; } /* Check the login cookie to see if it matches a known valid user. */ - if( uid==0 ){ - if( (zCookie = P(login_cookie_name()))!=0 ){ - uid = db_int(0, - "SELECT uid FROM user" - " WHERE uid=%d" - " AND cookie=%Q" - " AND ipaddr=%Q" - " AND cexpire>julianday('now')", - atoi(zCookie), zCookie, zRemoteAddr - ); - }else{ - uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'"); - } + if( uid==0 && (zCookie = P(login_cookie_name()))!=0 ){ + uid = db_int(0, + "SELECT 1 FROM user" + " WHERE uid=%d" + " AND cookie=%Q" + " AND ipaddr=%Q" + " AND cexpire>julianday('now')", + atoi(zCookie), zCookie, zRemoteAddr + ); } if( uid==0 ){ g.isAnon = 1; g.zLogin = "";
Modified src/xfer.c from [a734598a7e] to [5c87619787].
@@ -129,10 +129,11 @@ /* ** 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; #if 0 @@ -156,16 +157,17 @@ " SELECT rid FROM delta WHERE srcid=%d", 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 ){ if( pOut ){ @@ -176,10 +178,17 @@ free(zUuid); } } } 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 return nSent;