-fix #2598
[oweals/gnunet.git] / src / fs / gnunet-publish.c
index ef48f2d9293d7e983ec3fe66e2c26c1b256c55f1..eb64cc4cc32c4bb6b3cdb4689fe457dd842ec9d0 100644 (file)
@@ -28,7 +28,7 @@
 #include "platform.h"
 #include "gnunet_fs_service.h"
 
-static int ret;
+static int ret = 1;
 
 static int verbose;
 
@@ -134,7 +134,8 @@ stop_scanner_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 static void *
 progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 {
-  char *s;
+  const char *s;
+  char *suri;
 
   switch (info->status)
   {
@@ -143,12 +144,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
     if (verbose)
     {
-      s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta);
+      s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta,
+                                                 GNUNET_YES);
       FPRINTF (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"),
                info->value.publish.filename,
                (unsigned long long) info->value.publish.completed,
                (unsigned long long) info->value.publish.size, s);
-      GNUNET_free (s);
     }
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
@@ -164,10 +165,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
   case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
     FPRINTF (stdout, _("Publishing `%s' done.\n"),
              info->value.publish.filename);
-    s = GNUNET_FS_uri_to_string (info->value.publish.specifics.
+    suri = GNUNET_FS_uri_to_string (info->value.publish.specifics.
                                  completed.chk_uri);
-    FPRINTF (stdout, _("URI is `%s'.\n"), s);
-    GNUNET_free (s);
+    FPRINTF (stdout, _("URI is `%s'.\n"), suri);
+    GNUNET_free (suri);
     if (info->value.publish.pctx == NULL)
     {
       if (kill_task != GNUNET_SCHEDULER_NO_TASK)
@@ -177,6 +178,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
       }
       kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL);
     }
+    ret = 0;
     break;
   case GNUNET_FS_STATUS_PUBLISH_STOPPED:
     GNUNET_break (NULL == pc);