Thu, 12 Oct 2017 20:37:46 +0200
adds dav get option to keep existing files
dav/main.c | file | annotate | diff | comparison | revisions | |
dav/optparser.c | file | annotate | diff | comparison | revisions | |
dav/sync.h | file | annotate | diff | comparison | revisions | |
dav/version.h | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Mon Oct 09 14:55:47 2017 +0200 +++ b/dav/main.c Thu Oct 12 20:37:46 2017 +0200 @@ -161,7 +161,7 @@ fprintf(stderr, " list [-altdepcR] [-u <date>] <url>\n"); fprintf( stderr, - " get [-pcR] [-o <file>] [-u <date>] <url>\n"); + " get [-pcRK] [-o <file>] [-u <date>] <url>\n"); fprintf(stderr, " put [-pcR] [-k <key>] [-L <lock>] <url> <file>\n"); fprintf(stderr, " mkdir [-pc] [-k <key>] [-L <lock>] <url>\n"); fprintf(stderr, " remove [-pc] [-L <lock>] <url>\n"); @@ -189,6 +189,7 @@ fprintf(stderr, " -R " "Recursively do the operation for all children\n"); + fprintf(stderr, " -K Keep already present files\n"); fprintf(stderr, " -o <file> Write output to file\n"); fprintf( stderr, @@ -747,12 +748,27 @@ return 0; } + int isstdout = !strcmp(out, "-"); + if(cmd_getoption(a, "keep") && !isstdout) { + struct stat s; + if(stat(out, &s)) { + if(errno != ENOENT) { + perror("stat"); + } + } else { + if(cmd_getoption(a, "recursive")) { + printf("skip: %s\n", res->path); + } + return 0; + } + } + // print some status message in recursive mode if(cmd_getoption(a, "recursive")) { printf("get: %s\n", res->path); } - - FILE *fout = !strcmp(out, "-") ? stdout : fopen(out, "wb"); + + FILE *fout = isstdout ? stdout : fopen(out, "wb"); if(!fout) { fprintf(stderr, "cannot open output file\n"); return -1;
--- a/dav/optparser.c Mon Oct 09 14:55:47 2017 +0200 +++ b/dav/optparser.c Thu Oct 12 20:37:46 2017 +0200 @@ -128,6 +128,10 @@ ucx_map_cstr_put(a->options, "structure", NOARG); break; } + case 'K': { + ucx_map_cstr_put(a->options, "keep", NOARG); + break; + } case 'o': { if(!option) { option = "output";