Browse code

Resets behavior of freshclam --show-progress option to be on by default if stdout is a TTY.

Micah Snyder authored on 2019/08/05 06:44:20
Showing 2 changed files
... ...
@@ -230,6 +230,8 @@ fc_error_t download_complete_callback(const char *dbFilename, void *context)
230 230
     logg("*download_complete_callback:   fc_context->bTestDatabases   : %u\n", fc_context->bBytecodeEnabled);
231 231
     logg("*download_complete_callback:   fc_context->bBytecodeEnabled : %u\n", fc_context->bBytecodeEnabled);
232 232
 
233
+    printf("Testing database: '%s' ...\n", dbFilename);
234
+
233 235
     if (fc_context->bTestDatabases) {
234 236
 #ifdef WIN32
235 237
 
... ...
@@ -238,7 +240,7 @@ fc_error_t download_complete_callback(const char *dbFilename, void *context)
238 238
         } __except (logg("!Exception during database testing, code %08x\n",
239 239
                          GetExceptionCode()),
240 240
                     EXCEPTION_CONTINUE_SEARCH) {
241
-            status = FC_ETESTFAIL;
241
+            ret = FC_ETESTFAIL;
242 242
         }
243 243
         if (FC_SUCCESS != ret) {
244 244
             logg("^Database load exited with \"%s\" (%d)\n", fc_strerror(ret), ret);
... ...
@@ -364,6 +366,13 @@ fc_error_t download_complete_callback(const char *dbFilename, void *context)
364 364
     status = FC_SUCCESS;
365 365
 
366 366
 done:
367
+
368
+    if (FC_SUCCESS == status) {
369
+        printf("Database test passed.\n");
370
+    } else {
371
+        printf("Database test FAILED.\n");
372
+    }
373
+
367 374
     g_sigchildWait = 1;
368 375
 
369 376
     return status;
... ...
@@ -553,7 +553,12 @@ static fc_error_t remote_cvdhead(
553 553
         goto done;
554 554
     }
555 555
 
556
-    if (mprintf_progress) {
556
+#ifdef HAVE_UNISTD_H
557
+    if (!mprintf_quiet && (mprintf_progress || isatty(fileno(stdout))))
558
+#else
559
+    if (!mprintf_quiet)
560
+#endif
561
+    {
557 562
         prog.lastRunTime = 0;
558 563
         prog.curl        = curl;
559 564
         prog.bComplete   = 0;
... ...
@@ -811,7 +816,12 @@ static fc_error_t downloadFile(
811 811
         goto done;
812 812
     }
813 813
 
814
-    if (mprintf_progress) {
814
+#ifdef HAVE_UNISTD_H
815
+    if (!mprintf_quiet && (mprintf_progress || isatty(fileno(stdout))))
816
+#else
817
+    if (!mprintf_quiet)
818
+#endif
819
+    {
815 820
         prog.lastRunTime = 0;
816 821
         prog.curl        = curl;
817 822
         prog.bComplete   = 0;
... ...
@@ -1874,7 +1884,12 @@ fc_error_t updatedb(
1874 1874
             goto done;
1875 1875
         }
1876 1876
 
1877
-        if (mprintf_progress) {
1877
+#ifdef HAVE_UNISTD_H
1878
+        if (!mprintf_quiet && (mprintf_progress || isatty(fileno(stdout))))
1879
+#else
1880
+        if (!mprintf_quiet)
1881
+#endif
1882
+        {
1878 1883
             if (remoteVersion - localVersion == 1) {
1879 1884
                 mprintf("Current database is 1 version behind.\n");
1880 1885
             } else {
... ...
@@ -1887,7 +1902,12 @@ fc_error_t updatedb(
1887 1887
                 if (logerr)
1888 1888
                     llogerr = (j == g_maxAttempts);
1889 1889
 
1890
-                if (mprintf_progress) {
1890
+#ifdef HAVE_UNISTD_H
1891
+                if (!mprintf_quiet && (mprintf_progress || isatty(fileno(stdout))))
1892
+#else
1893
+                if (!mprintf_quiet)
1894
+#endif
1895
+                {
1891 1896
                     mprintf("Downloading database patch # %u...\n", i);
1892 1897
                 }
1893 1898
                 ret = downloadPatch(database, tmpdir, i, server, llogerr);