minor bugfixes
authorChristian Grothoff <christian@grothoff.org>
Tue, 20 Oct 2009 19:39:44 +0000 (19:39 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 20 Oct 2009 19:39:44 +0000 (19:39 +0000)
src/fs/fs_directory.c
src/fs/fs_download.c
src/fs/fs_file_information.c
src/fs/gnunet-download.c
src/fs/gnunet-publish.c
src/fs/gnunet-service-fs.c
src/fs/gnunet-unindex.c

index 00407ad3a0b18d584d76bfa7909f2d06eb580305..e037130c81ff53e8382fe68d1ecafaa5f2b14b38 100644 (file)
@@ -313,6 +313,7 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
                                 const struct GNUNET_CONTAINER_MetaData *md,
                                 const void *data)
 {
+  struct GNUNET_FS_Uri *curi;
   struct BuilderEntry *e;
   uint64_t fsize;
   uint32_t big;
@@ -330,7 +331,11 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
     if (GNUNET_FS_uri_test_chk (uri))
       fsize = GNUNET_FS_uri_chk_get_file_size (uri);
     else
-      fsize = GNUNET_FS_uri_chk_get_file_size (GNUNET_FS_uri_loc_get_uri (uri));
+      {
+       curi = GNUNET_FS_uri_loc_get_uri (uri);
+       fsize = GNUNET_FS_uri_chk_get_file_size (curi);
+       GNUNET_FS_uri_destroy (curi);
+      }
   else
     fsize = 0; /* not given */
   if (fsize > MAX_INLINE_SIZE)
index 3054048e4ec2632ac785e817823d0fc9ca302244..ca1a8325aba1bdbcf6ff694264947138c5e08f1d 100644 (file)
@@ -766,19 +766,19 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
   struct GNUNET_FS_DownloadContext *dc;
   struct GNUNET_CLIENT_Connection *client;
 
-  client = GNUNET_CLIENT_connect (h->sched,
-                                 "fs",
-                                 h->cfg);
-  if (NULL == client)
-    return NULL;
-  // FIXME: add support for "loc" URIs!
   GNUNET_assert (GNUNET_FS_uri_test_chk (uri));
   if ( (offset + length < offset) ||
        (offset + length > uri->data.chk.file_length) )
-    {
+    {      
       GNUNET_break (0);
       return NULL;
     }
+  client = GNUNET_CLIENT_connect (h->sched,
+                                 "fs",
+                                 h->cfg);
+  if (NULL == client)
+    return NULL;
+  // FIXME: add support for "loc" URIs!
 #if DEBUG_DOWNLOAD
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Starting download `%s' of %llu bytes\n",
index d1d897b24af8fa3fe24158c3270d21bc84f4894e..f4f4fb5673f5e386d0a1292f35adae649ea93bbb 100644 (file)
@@ -633,6 +633,7 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
                                                           anonymity,
                                                           priority,
                                                           expirationTime);
+  GNUNET_CONTAINER_meta_data_destroy (meta);
   ret->data.dir.entries = dc.entries;
   while (dc.entries != NULL)
     {
index bf3daa68feeb75e5b4659903d31f9cbb87ca88a2..1c28cf7c96e36087c4c7567ec64ec562ddad92b9 100644 (file)
@@ -64,19 +64,28 @@ static void *
 progress_cb (void *cls,
             const struct GNUNET_FS_ProgressInfo *info)
 {
+  char *s;
+  char *t;
+
   switch (info->status)
     {
     case GNUNET_FS_STATUS_DOWNLOAD_START:
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
       if (verbose)
-       fprintf (stdout,
-                _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"),
-                info->value.download.filename,
-                (unsigned long long) info->value.download.completed,
-                (unsigned long long) info->value.download.size,
-                GNUNET_STRINGS_relative_time_to_string(info->value.download.eta),
-                GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1)));
+       {
+         s = GNUNET_STRINGS_relative_time_to_string(info->value.download.eta);
+         t = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1));
+         fprintf (stdout,
+                  _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"),
+                  info->value.download.filename,
+                  (unsigned long long) info->value.download.completed,
+                  (unsigned long long) info->value.download.size,
+                  s,
+                  t);
+         GNUNET_free (s);
+         GNUNET_free (t);
+       }
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
       fprintf (stderr,
@@ -85,10 +94,12 @@ progress_cb (void *cls,
       GNUNET_FS_download_stop (dc, delete_incomplete); 
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
+      s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1));
       fprintf (stdout,
               _("Downloading `%s' done (%s/s).\n"),
               info->value.download.filename,
-              GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.value + 1)));
+              s);
+      GNUNET_free (s);
       if (info->value.download.dc == dc)
        GNUNET_FS_download_stop (dc, delete_incomplete);
       break;
index 777370c90fe54e9d83badb42c2665c24030f682b..e3918f6fb8a9383013a5394ab183da169a2cef98 100644 (file)
@@ -87,18 +87,24 @@ static void *
 progress_cb (void *cls,
             const struct GNUNET_FS_ProgressInfo *info)
 {
+  char *s;
+
   switch (info->status)
     {
     case GNUNET_FS_STATUS_PUBLISH_START:
       break;
     case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
       if (verbose)
-       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,
-                GNUNET_STRINGS_relative_time_to_string(info->value.publish.eta));
+       {
+         s = GNUNET_STRINGS_relative_time_to_string(info->value.publish.eta);
+         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:
       fprintf (stderr,
index ed817e8484e27993c4ac5f49dadb4a34813aa541..0eede0c99fa215208fa23d73f6be36fdbb45cc11 100644 (file)
@@ -920,6 +920,7 @@ read_index_list ()
          pos->next = indexed_files;
          indexed_files = pos;
        }
+      GNUNET_free (fname);
     }
   if (GNUNET_OK != 
       GNUNET_BIO_read_close (rh, &emsg))
index cce08bb20f8f4650f2db353a44791df098d16375..c6b75c9c308f60f297484623cf40c60804a50370 100644 (file)
@@ -56,17 +56,23 @@ static void *
 progress_cb (void *cls,
             const struct GNUNET_FS_ProgressInfo *info)
 {
+  char *s;
+
   switch (info->status)
     {
     case GNUNET_FS_STATUS_UNINDEX_START:
       break;
     case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
       if (verbose)
-       fprintf (stdout,
-                _("Unindexing at %llu/%llu (%s remaining)\n"),
-                (unsigned long long) info->value.unindex.completed,
-                (unsigned long long) info->value.unindex.size,
-                GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta));
+       {
+         s = GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta);
+         fprintf (stdout,
+                  _("Unindexing at %llu/%llu (%s remaining)\n"),
+                  (unsigned long long) info->value.unindex.completed,
+                  (unsigned long long) info->value.unindex.size,
+                  s);
+         GNUNET_free (s);
+       }
       break;
     case GNUNET_FS_STATUS_UNINDEX_ERROR:
       fprintf (stderr,