From 9509b69ad5bc2f86234586935eeb7af6207d712b Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 3 Dec 2018 10:22:40 +0000 Subject: [PATCH] move progress bar --- zpm-syncfs.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/zpm-syncfs.c b/zpm-syncfs.c index 66e5aaa..9a50be1 100644 --- a/zpm-syncfs.c +++ b/zpm-syncfs.c @@ -628,6 +628,20 @@ static int remove_files(void *f, int ncols, char **vals, char **cols) { return 0; } + if (conf->verbose) { + if (conf->progress == 2) { + fprintf(stderr, "%s(%s)\n", flags ? "rmdir" : "unlink", dest); + } else if (conf->progress == 1) { + /* overwrite */ + pdots(50, '.', conf->ops_completed, conf->ops_completed + 1, conf->ops_total); + conf->ops_completed++; + conf->ops_completed++; + } else { + pdots(50, '.', conf->ops_completed, conf->ops_completed + 1, conf->ops_total); + conf->ops_completed++; + } + } + errno = 0; if (lstat(dest, &st) == -1) { @@ -635,10 +649,6 @@ static int remove_files(void *f, int ncols, char **vals, char **cols) { case ENOENT: /* TODO chatter if verbose */ break; - case ENOTEMPTY: /* fall through */ - case EEXIST: - /* TODO chatter, or possibly require */ - break; default: return seterror(conf, "can't stat %s: %s", dest, strerror(errno)); } @@ -650,19 +660,6 @@ static int remove_files(void *f, int ncols, char **vals, char **cols) { } /* TODO check that expected filetype matches actual filetype */ - if (conf->verbose) { - if (conf->progress == 2) { - fprintf(stderr, "%s(%s)\n", flags ? "rmdir" : "unlink", dest); - } else if (conf->progress == 1) { - /* overwrite */ - pdots(50, '.', conf->ops_completed, conf->ops_completed + 1, conf->ops_total); - conf->ops_completed++; - conf->ops_completed++; - } else { - pdots(50, '.', conf->ops_completed, conf->ops_completed + 1, conf->ops_total); - conf->ops_completed++; - } - } errno = 0; @@ -670,6 +667,10 @@ static int remove_files(void *f, int ncols, char **vals, char **cols) { switch (errno) { case ENOENT: break; + case ENOTEMPTY: /* fall through */ + case EEXIST: + /* TODO chatter, or possibly require */ + break; default: return seterror(conf, "can't unlink %s: %s", dest, strerror(errno)); } -- 2.40.0