Make the output from sqlite3-rsync with a single -v option the same as it

is with regular rsync.  Only show the SSH command with two or more -v options,
or if there is an error in popen2().

FossilOrigin-Name: 105ec44b470318fc9ff1773027c4064343f224068c9b6e71c5618f18f7dfcc3f
This commit is contained in:
drh 2024-09-14 10:48:05 +00:00
parent 33f0a3ed13
commit 2b30518804
3 changed files with 49 additions and 21 deletions

View File

@ -1,5 +1,5 @@
C Merge\ssqlite_dbpage\sfixes\sinto\sthe\ssqlite3-rsync\sbranch.
D 2024-09-13T23:41:16.081
C Make\sthe\soutput\sfrom\ssqlite3-rsync\swith\sa\ssingle\s-v\soption\sthe\ssame\sas\sit\nis\swith\sregular\srsync.\s\sOnly\sshow\sthe\sSSH\scommand\swith\stwo\sor\smore\s-v\soptions,\nor\sif\sthere\sis\san\serror\sin\spopen2().
D 2024-09-14T10:48:05.083
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -2174,7 +2174,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x
F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60
F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a
F tool/sqlite3-rsync.c 3097aa389c41780bc52ad59d5205dafabb229f7d38ea8fbcd9f47d431ce6c0b1
F tool/sqlite3-rsync.c bb2e19ff46b9679b2c605c474f16a237d81784a819ea6a9265c4d405f323c6e9
F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 86e0219d977c493ac19d00c3ddcf560eb317d506c7cf6e4ef17e92daa91e1762 6aa9c8e79b440c6419e65990d9ceba8f00a6f975455138cf2aa82b113daec825
R 9005fc31425a0253e67d368b9122f599
P dff76b7a3436031ea5a61b8a44ddfa1d40ea20c983f3d34a8501cd7074db68b8
R 95aaf9a89250b8760572431cb6032176
U drh
Z 4975b1813e58aa71fc8abcda1ea8ca48
Z abc0757084d259b46638ccae491d778a
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
dff76b7a3436031ea5a61b8a44ddfa1d40ea20c983f3d34a8501cd7074db68b8
105ec44b470318fc9ff1773027c4064343f224068c9b6e71c5618f18f7dfcc3f

View File

@ -1497,6 +1497,17 @@ static const char *cmdline_option_value(int argc, const char * const*argv,
return argv[i];
}
/*
** Return the current time in milliseconds since the Julian epoch.
*/
sqlite3_int64 currentTime(void){
sqlite3_int64 now = 0;
sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
if( pVfs && pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64!=0 ){
pVfs->xCurrentTimeInt64(pVfs, &now);
}
return now;
}
/*
** Parse command-line arguments. Dispatch subroutines to do the
@ -1536,6 +1547,9 @@ int main(int argc, char const * const *argv){
const char *zSsh = "ssh";
const char *zExe = "sqlite3-rsync";
char *zCmd = 0;
sqlite3_int64 tmStart;
sqlite3_int64 tmEnd;
sqlite3_int64 tmElapse;
#define cli_opt_val cmdline_option_value(argc, argv, ++i)
memset(&ctx, 0, sizeof(ctx));
@ -1629,6 +1643,7 @@ int main(int argc, char const * const *argv){
fprintf(stderr, "missing REPLICA database filename\n");
return 1;
}
tmStart = currentTime();
zDiv = strchr(ctx.zOrigin,':');
if( zDiv ){
if( strchr(ctx.zReplica,':')!=0 ){
@ -1652,7 +1667,7 @@ int main(int argc, char const * const *argv){
append_escaped_arg(pStr, zDiv, 1);
append_escaped_arg(pStr, file_tail(ctx.zReplica), 1);
zCmd = sqlite3_str_finish(pStr);
if( ctx.eVerbose ) printf("%s\n", zCmd);
if( ctx.eVerbose>=2 ) printf("%s\n", zCmd);
if( popen2(zCmd, &ctx.pIn, &ctx.pOut, &childPid, 0) ){
fprintf(stderr, "Could not start auxiliary process: %s\n", zCmd);
return 1;
@ -1674,7 +1689,7 @@ int main(int argc, char const * const *argv){
append_escaped_arg(pStr, file_tail(ctx.zOrigin), 1);
append_escaped_arg(pStr, zDiv, 1);
zCmd = sqlite3_str_finish(pStr);
if( ctx.eVerbose ) printf("%s\n", zCmd);
if( ctx.eVerbose>=2 ) printf("%s\n", zCmd);
if( popen2(zCmd, &ctx.pIn, &ctx.pOut, &childPid, 0) ){
fprintf(stderr, "Could not start auxiliary process: %s\n", zCmd);
return 1;
@ -1691,29 +1706,42 @@ int main(int argc, char const * const *argv){
append_escaped_arg(pStr, ctx.zOrigin, 1);
append_escaped_arg(pStr, ctx.zReplica, 1);
zCmd = sqlite3_str_finish(pStr);
if( ctx.eVerbose ) printf("%s\n", zCmd);
if( ctx.eVerbose>=2 ) printf("%s\n", zCmd);
if( popen2(zCmd, &ctx.pIn, &ctx.pOut, &childPid, 0) ){
fprintf(stderr, "Could not start auxiliary process: %s\n", zCmd);
return 1;
}
originSide(&ctx);
}
tmEnd = currentTime();
tmElapse = tmEnd - tmStart; /* Elapse time in milliseconds */
if( ctx.nErr ){
printf("Databases where not synced due to errors\n");
}
if( ctx.eVerbose==1 ){
printf("Network traffic is %.1f%% of database size\n",
(100.0*(double)(ctx.nIn+ctx.nOut))/(ctx.szPage*(double)ctx.nPage));
}
if( ctx.eVerbose>=2 ){
if( ctx.nErr ) printf("%d errors, ", ctx.nErr);
printf("%lld bytes sent, %lld bytes received\n", ctx.nOut, ctx.nIn);
if( ctx.eVerbose>=2 ){
printf("Database is %u pages of %u bytes each.\n",
ctx.nPage, ctx.szPage);
printf("Sent %u hashes, %u page contents\n",
ctx.nHashSent, ctx.nPageSent);
char *zMsg;
sqlite3_int64 szTotal = (sqlite3_int64)ctx.nPage*(sqlite3_int64)ctx.szPage;
sqlite3_int64 nIO = ctx.nOut +ctx.nIn;
zMsg = sqlite3_mprintf("sent %,lld bytes, received %,lld bytes",
ctx.nOut, ctx.nIn);
printf("%s", zMsg);
sqlite3_free(zMsg);
if( tmElapse>0 ){
zMsg = sqlite3_mprintf(", %,.2f bytes/sec",
1000.0*(double)nIO/(double)tmElapse);
printf("%s\n", zMsg);
sqlite3_free(zMsg);
}else{
printf("\n");
}
if( nIO<=szTotal && nIO>0 ){
zMsg = sqlite3_mprintf("total size %,lld speedup is %.2f",
szTotal, (double)szTotal/(double)nIO);
}else{
zMsg = sqlite3_mprintf("total size %,lld", szTotal);
}
printf("%s\n", zMsg);
sqlite3_free(zMsg);
}
sqlite3_free(zCmd);
if( pIn!=0 && pOut!=0 ){