diff options
Diffstat (limited to 'src/update.c')
-rw-r--r-- | src/update.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/update.c b/src/update.c index f063686..e0e7f9c 100644 --- a/src/update.c +++ b/src/update.c @@ -126,6 +126,7 @@ static int handle_file(struct syrep_db_context *c, uint32_t version, const char } static int iterate_dir(struct syrep_db_context *c, struct syrep_md_cache *cache, uint32_t version, const char *root) { + int r = -1; DIR *dir; struct dirent *de; char p[PATH_MAX]; @@ -143,6 +144,11 @@ static int iterate_dir(struct syrep_db_context *c, struct syrep_md_cache *cache, if (!strncmp(de->d_name, ".syrep", 6)) continue; + if (interrupted) { + fprintf(stderr, "Canceled.\n"); + goto finish; + } + if (args.progress_flag) rotdash(); @@ -157,21 +163,24 @@ static int iterate_dir(struct syrep_db_context *c, struct syrep_md_cache *cache, if (S_ISDIR(st.st_mode)) { if (iterate_dir(c, cache, version, p) < 0) - fprintf(stderr, "iterate_dir(%s) failed: %s\n", p, strerror(errno)); + goto finish; + } else if (S_ISREG(st.st_mode)) { if (md_cache_get(cache, p, md.digest) < 0) - continue; + goto finish; - if ((handle_file(c, version, p, &md)) < 0) { - fprintf(stderr, "handle_file(%s) failed.\n", p); - return -1; - } + if ((handle_file(c, version, p, &md)) < 0) + goto finish; } } + + r = 0; + +finish: closedir(dir); - return 0; + return r; } static int new_version(struct syrep_db_context *c, uint32_t v, uint32_t t) { @@ -217,6 +226,9 @@ int update(struct syrep_db_context *c, struct syrep_md_cache *cache) { if (iterate_dir(c, cache, version, ".") < 0) return -1; + if (args.progress_flag) + rotdash_hide(); + if (new_version(c, version, now) < 0) return -1; |