Fossil SCM
Create a valid rcvfrom entry when adding unversioned content from the command-line.
Commit
7deeb51511eca1390c0c2126540e71ade55adfd5
Parent
06aec61111d5e2f…
2 files changed
+18
-5
+3
+18
-5
| --- src/unversioned.c | ||
| +++ src/unversioned.c | ||
| @@ -207,10 +207,12 @@ | ||
| 207 | 207 | |
| 208 | 208 | zAs = find_option("as",0,1); |
| 209 | 209 | if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE"); |
| 210 | 210 | verify_all_options(); |
| 211 | 211 | db_begin_transaction(); |
| 212 | + user_select(); | |
| 213 | + g.zIpAddr = "command-line"; | |
| 212 | 214 | content_rcvid_init(); |
| 213 | 215 | db_prepare(&ins, |
| 214 | 216 | "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)" |
| 215 | 217 | " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)" |
| 216 | 218 | ); |
| @@ -371,33 +373,41 @@ | ||
| 371 | 373 | } |
| 372 | 374 | db_prepare(&q, |
| 373 | 375 | "SELECT" |
| 374 | 376 | " name," |
| 375 | 377 | " mtime," |
| 376 | - " hash IS NULL," | |
| 377 | - " sz" | |
| 378 | + " hash," | |
| 379 | + " sz," | |
| 380 | + " (SELECT login FROM rcvfrom, user" | |
| 381 | + " WHERE user.uid=rcvfrom.uid AND rcvfrom.rcvid=unversioned.rcvid)" | |
| 378 | 382 | " FROM unversioned" |
| 379 | 383 | ); |
| 380 | 384 | iNow = db_int64(0, "SELECT strftime('%%s','now');"); |
| 381 | 385 | while( db_step(&q)==SQLITE_ROW ){ |
| 382 | 386 | const char *zName = db_column_text(&q, 0); |
| 383 | 387 | sqlite3_int64 mtime = db_column_int(&q, 1); |
| 384 | - int isDeleted = db_column_int(&q, 2); | |
| 388 | + const char *zHash = db_column_text(&q, 2); | |
| 389 | + int isDeleted = zHash==0; | |
| 385 | 390 | int fullSize = db_column_int(&q, 3); |
| 386 | 391 | char *zAge = human_readable_age((iNow - mtime)/86400.0); |
| 392 | + const char *zLogin = db_column_text(&q, 4); | |
| 393 | + if( zLogin==0 ) zLogin = ""; | |
| 387 | 394 | if( (n++)==0 ){ |
| 388 | 395 | @ <div class="uvlist"> |
| 389 | 396 | @ <table cellpadding="2" cellspacing="0" border="1" id="uvtab"> |
| 390 | 397 | @ <thead><tr> |
| 391 | 398 | @ <th> Name |
| 392 | 399 | @ <th> Age |
| 393 | 400 | @ <th> Size |
| 401 | + @ <th> User | |
| 402 | + @ <th> SHA1 | |
| 394 | 403 | @ </tr></thead> |
| 395 | 404 | @ <tbody> |
| 396 | 405 | } |
| 397 | 406 | if( isDeleted ){ |
| 398 | 407 | sqlite3_snprintf(sizeof(zSzName), zSzName, "<i>Deleted</i>"); |
| 408 | + zHash = ""; | |
| 399 | 409 | fullSize = 0; |
| 400 | 410 | }else{ |
| 401 | 411 | approxSizeName(sizeof(zSzName), zSzName, fullSize); |
| 402 | 412 | iTotalSz += fullSize; |
| 403 | 413 | cnt++; |
| @@ -404,20 +414,23 @@ | ||
| 404 | 414 | } |
| 405 | 415 | @ <tr> |
| 406 | 416 | @ <td> <a href='%R/uv/%T(zName)'>%h(zName)</a> </td> |
| 407 | 417 | @ <td data-sortkey='%016llx(-mtime)'> %s(zAge) </td> |
| 408 | 418 | @ <td data-sortkey='%08x(fullSize)'> %s(zSzName) </td> |
| 419 | + @ <td> %h(zLogin) </td> | |
| 420 | + @ <td> %h(zHash) </td> | |
| 409 | 421 | @ </tr> |
| 410 | 422 | fossil_free(zAge); |
| 411 | 423 | } |
| 412 | 424 | db_finalize(&q); |
| 413 | 425 | if( n ){ |
| 414 | 426 | approxSizeName(sizeof(zSzName), zSzName, iTotalSz); |
| 415 | 427 | @ </tbody> |
| 416 | - @ <tfoot><tr><td><b>Total over %d(cnt) files</b><td><td>%s(zSzName)</tfoot> | |
| 428 | + @ <tfoot><tr><td><b>Total over %d(cnt) files</b><td><td>%s(zSzName) | |
| 429 | + @ <td><td></tfoot> | |
| 417 | 430 | @ </table></div> |
| 418 | - output_table_sorting_javascript("uvtab","tKk",1); | |
| 431 | + output_table_sorting_javascript("uvtab","tKktt",1); | |
| 419 | 432 | }else{ |
| 420 | 433 | @ No unversioned files on this server. |
| 421 | 434 | } |
| 422 | 435 | style_footer(); |
| 423 | 436 | } |
| 424 | 437 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -207,10 +207,12 @@ | |
| 207 | |
| 208 | zAs = find_option("as",0,1); |
| 209 | if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE"); |
| 210 | verify_all_options(); |
| 211 | db_begin_transaction(); |
| 212 | content_rcvid_init(); |
| 213 | db_prepare(&ins, |
| 214 | "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)" |
| 215 | " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)" |
| 216 | ); |
| @@ -371,33 +373,41 @@ | |
| 371 | } |
| 372 | db_prepare(&q, |
| 373 | "SELECT" |
| 374 | " name," |
| 375 | " mtime," |
| 376 | " hash IS NULL," |
| 377 | " sz" |
| 378 | " FROM unversioned" |
| 379 | ); |
| 380 | iNow = db_int64(0, "SELECT strftime('%%s','now');"); |
| 381 | while( db_step(&q)==SQLITE_ROW ){ |
| 382 | const char *zName = db_column_text(&q, 0); |
| 383 | sqlite3_int64 mtime = db_column_int(&q, 1); |
| 384 | int isDeleted = db_column_int(&q, 2); |
| 385 | int fullSize = db_column_int(&q, 3); |
| 386 | char *zAge = human_readable_age((iNow - mtime)/86400.0); |
| 387 | if( (n++)==0 ){ |
| 388 | @ <div class="uvlist"> |
| 389 | @ <table cellpadding="2" cellspacing="0" border="1" id="uvtab"> |
| 390 | @ <thead><tr> |
| 391 | @ <th> Name |
| 392 | @ <th> Age |
| 393 | @ <th> Size |
| 394 | @ </tr></thead> |
| 395 | @ <tbody> |
| 396 | } |
| 397 | if( isDeleted ){ |
| 398 | sqlite3_snprintf(sizeof(zSzName), zSzName, "<i>Deleted</i>"); |
| 399 | fullSize = 0; |
| 400 | }else{ |
| 401 | approxSizeName(sizeof(zSzName), zSzName, fullSize); |
| 402 | iTotalSz += fullSize; |
| 403 | cnt++; |
| @@ -404,20 +414,23 @@ | |
| 404 | } |
| 405 | @ <tr> |
| 406 | @ <td> <a href='%R/uv/%T(zName)'>%h(zName)</a> </td> |
| 407 | @ <td data-sortkey='%016llx(-mtime)'> %s(zAge) </td> |
| 408 | @ <td data-sortkey='%08x(fullSize)'> %s(zSzName) </td> |
| 409 | @ </tr> |
| 410 | fossil_free(zAge); |
| 411 | } |
| 412 | db_finalize(&q); |
| 413 | if( n ){ |
| 414 | approxSizeName(sizeof(zSzName), zSzName, iTotalSz); |
| 415 | @ </tbody> |
| 416 | @ <tfoot><tr><td><b>Total over %d(cnt) files</b><td><td>%s(zSzName)</tfoot> |
| 417 | @ </table></div> |
| 418 | output_table_sorting_javascript("uvtab","tKk",1); |
| 419 | }else{ |
| 420 | @ No unversioned files on this server. |
| 421 | } |
| 422 | style_footer(); |
| 423 | } |
| 424 |
| --- src/unversioned.c | |
| +++ src/unversioned.c | |
| @@ -207,10 +207,12 @@ | |
| 207 | |
| 208 | zAs = find_option("as",0,1); |
| 209 | if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE"); |
| 210 | verify_all_options(); |
| 211 | db_begin_transaction(); |
| 212 | user_select(); |
| 213 | g.zIpAddr = "command-line"; |
| 214 | content_rcvid_init(); |
| 215 | db_prepare(&ins, |
| 216 | "REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)" |
| 217 | " VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)" |
| 218 | ); |
| @@ -371,33 +373,41 @@ | |
| 373 | } |
| 374 | db_prepare(&q, |
| 375 | "SELECT" |
| 376 | " name," |
| 377 | " mtime," |
| 378 | " hash," |
| 379 | " sz," |
| 380 | " (SELECT login FROM rcvfrom, user" |
| 381 | " WHERE user.uid=rcvfrom.uid AND rcvfrom.rcvid=unversioned.rcvid)" |
| 382 | " FROM unversioned" |
| 383 | ); |
| 384 | iNow = db_int64(0, "SELECT strftime('%%s','now');"); |
| 385 | while( db_step(&q)==SQLITE_ROW ){ |
| 386 | const char *zName = db_column_text(&q, 0); |
| 387 | sqlite3_int64 mtime = db_column_int(&q, 1); |
| 388 | const char *zHash = db_column_text(&q, 2); |
| 389 | int isDeleted = zHash==0; |
| 390 | int fullSize = db_column_int(&q, 3); |
| 391 | char *zAge = human_readable_age((iNow - mtime)/86400.0); |
| 392 | const char *zLogin = db_column_text(&q, 4); |
| 393 | if( zLogin==0 ) zLogin = ""; |
| 394 | if( (n++)==0 ){ |
| 395 | @ <div class="uvlist"> |
| 396 | @ <table cellpadding="2" cellspacing="0" border="1" id="uvtab"> |
| 397 | @ <thead><tr> |
| 398 | @ <th> Name |
| 399 | @ <th> Age |
| 400 | @ <th> Size |
| 401 | @ <th> User |
| 402 | @ <th> SHA1 |
| 403 | @ </tr></thead> |
| 404 | @ <tbody> |
| 405 | } |
| 406 | if( isDeleted ){ |
| 407 | sqlite3_snprintf(sizeof(zSzName), zSzName, "<i>Deleted</i>"); |
| 408 | zHash = ""; |
| 409 | fullSize = 0; |
| 410 | }else{ |
| 411 | approxSizeName(sizeof(zSzName), zSzName, fullSize); |
| 412 | iTotalSz += fullSize; |
| 413 | cnt++; |
| @@ -404,20 +414,23 @@ | |
| 414 | } |
| 415 | @ <tr> |
| 416 | @ <td> <a href='%R/uv/%T(zName)'>%h(zName)</a> </td> |
| 417 | @ <td data-sortkey='%016llx(-mtime)'> %s(zAge) </td> |
| 418 | @ <td data-sortkey='%08x(fullSize)'> %s(zSzName) </td> |
| 419 | @ <td> %h(zLogin) </td> |
| 420 | @ <td> %h(zHash) </td> |
| 421 | @ </tr> |
| 422 | fossil_free(zAge); |
| 423 | } |
| 424 | db_finalize(&q); |
| 425 | if( n ){ |
| 426 | approxSizeName(sizeof(zSzName), zSzName, iTotalSz); |
| 427 | @ </tbody> |
| 428 | @ <tfoot><tr><td><b>Total over %d(cnt) files</b><td><td>%s(zSzName) |
| 429 | @ <td><td></tfoot> |
| 430 | @ </table></div> |
| 431 | output_table_sorting_javascript("uvtab","tKktt",1); |
| 432 | }else{ |
| 433 | @ No unversioned files on this server. |
| 434 | } |
| 435 | style_footer(); |
| 436 | } |
| 437 |
+3
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -345,10 +345,13 @@ | ||
| 345 | 345 | nullContent = 1; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /* The isWriter flag must be true in order to land the new file */ |
| 349 | 349 | if( !isWriter ) goto end_accept_unversioned_file; |
| 350 | + | |
| 351 | + /* Make sure we have a valid g.rcvid marker */ | |
| 352 | + content_rcvid_init(); | |
| 350 | 353 | |
| 351 | 354 | /* Check to see if current content really should be overwritten. Ideally, |
| 352 | 355 | ** a uvfile card should never have been sent unless the overwrite should |
| 353 | 356 | ** occur. But do not trust the sender. Double-check. |
| 354 | 357 | */ |
| 355 | 358 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -345,10 +345,13 @@ | |
| 345 | nullContent = 1; |
| 346 | } |
| 347 | |
| 348 | /* The isWriter flag must be true in order to land the new file */ |
| 349 | if( !isWriter ) goto end_accept_unversioned_file; |
| 350 | |
| 351 | /* Check to see if current content really should be overwritten. Ideally, |
| 352 | ** a uvfile card should never have been sent unless the overwrite should |
| 353 | ** occur. But do not trust the sender. Double-check. |
| 354 | */ |
| 355 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -345,10 +345,13 @@ | |
| 345 | nullContent = 1; |
| 346 | } |
| 347 | |
| 348 | /* The isWriter flag must be true in order to land the new file */ |
| 349 | if( !isWriter ) goto end_accept_unversioned_file; |
| 350 | |
| 351 | /* Make sure we have a valid g.rcvid marker */ |
| 352 | content_rcvid_init(); |
| 353 | |
| 354 | /* Check to see if current content really should be overwritten. Ideally, |
| 355 | ** a uvfile card should never have been sent unless the overwrite should |
| 356 | ** occur. But do not trust the sender. Double-check. |
| 357 | */ |
| 358 |