aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-09-13 18:28:43 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-09-13 18:28:43 +0200
commit9a9234dc46a0584f5f8ffd043ca5765f1e97f81e (patch)
tree171a461867cde7dfcde329a007b4d77478588bf1
parentc051a960e6fe09e2425dc223018b87a453b2bb2a (diff)
downloadOFQT-9a9234dc46a0584f5f8ffd043ca5765f1e97f81e.tar.gz
OFQT-9a9234dc46a0584f5f8ffd043ca5765f1e97f81e.zip
move mirror printing to stdout to generalize, disable stdout buffering
-rw-r--r--src/mirror/main.c9
1 files 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];