From 9a9234dc46a0584f5f8ffd043ca5765f1e97f81e Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 13 Sep 2022 18:28:43 +0200 Subject: move mirror printing to stdout to generalize, disable stdout buffering --- src/mirror/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mirror/main.c b/src/mirror/main.c index 89a085d..a84bbf9 100644 --- a/src/mirror/main.c +++ b/src/mirror/main.c @@ -24,7 +24,7 @@ static void* thread_download(void* pinfo) if (info) { struct file_info* file = info->file; - fprintf(stderr, "\r [%i][%li/%li] Processing %s", info->i, info->j+1, info->rev->file_count, file->object); + printf("\r [%i][%li/%li] Processing %s", info->i, info->j+1, info->rev->file_count, file->object); // downloadObject checks if an object with the current hash is already present downloadObject(info->output_dir, info->remote, info->file); @@ -98,6 +98,9 @@ int main(int argc, char** argv) makeDir(revisions_dir); } + // disable stdout buffering to allow progress output + setvbuf(stdout, NULL, _IONBF, 0); + // download objects printf("Downloading objects\n"); int latest_rev = getLatestRemoteRevision(remote); @@ -114,7 +117,7 @@ int main(int argc, char** argv) for (int i = 0; i <= latest_rev; ++i) { - fprintf(stderr, "\r [%i] Downloading", i); + printf("\r [%i] Downloading", i); sprintf(revisions_dir_end, "%s%i", OS_PATH_SEP, i); len = strlen(remote) + 1 + strlen(TOAST_REVISIONS_ENDPOINT) + 1 + rev_len + 1; @@ -127,7 +130,7 @@ int main(int argc, char** argv) struct thread_object_info* thread_info = malloc(sizeof(struct thread_object_info) * rev->file_count); struct pool_t* pool = pool_init(); - fprintf(stderr, "\r [%i] Preparing ", i); + printf("\r [%i] Preparing ", i); for (size_t j = 0; j < rev->file_count; ++j) { struct file_info* file = &rev->files[j]; -- cgit v1.2.3