-also user gnunet-original filename here more consistently
authorChristian Grothoff <christian@grothoff.org>
Fri, 3 Feb 2012 21:55:39 +0000 (21:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 3 Feb 2012 21:55:39 +0000 (21:55 +0000)
src/fs/fs_dirmetascan.c
src/fs/fs_uri.c
src/util/container_meta_data.c
src/util/pseudonym.c
src/util/strings.c

index 543701ca2533416d4fd12103f6e5d3d6bce91f13..34170a8d4d0f9c6d54615ef06896dc42cbd4071a 100644 (file)
@@ -194,6 +194,7 @@ expand_tree (struct GNUNET_FS_ShareTreeItem *parent,
             int is_directory)
 {
   struct GNUNET_FS_ShareTreeItem *chld;
+  size_t slen;
 
   chld = GNUNET_malloc (sizeof (struct GNUNET_FS_ShareTreeItem));
   chld->parent = parent;
@@ -202,6 +203,12 @@ expand_tree (struct GNUNET_FS_ShareTreeItem *parent,
                   "%s%s",
                   GNUNET_STRINGS_get_short_name (filename),
                   is_directory ? "/" : "");
+  /* make sure we do not end with '//' */
+  slen = strlen (chld->short_filename);
+  if ( (slen >= 2) &&
+       (chld->short_filename[slen-1] == '/') &&
+       (chld->short_filename[slen-2] == '/') )
+    chld->short_filename[slen-1] = '\0';
   chld->is_directory = is_directory;
   if (NULL != parent)
       GNUNET_CONTAINER_DLL_insert (parent->children_head,
@@ -360,8 +367,9 @@ process_helper_msgs (void *cls,
        GNUNET_CONTAINER_meta_data_delete (ds->pos->meta, 
                                           EXTRACTOR_METATYPE_FILENAME,
                                           NULL, 0);
+       /* instead, put in our 'safer' original filename */
        GNUNET_CONTAINER_meta_data_insert (ds->pos->meta, "<libgnunetfs>",
-                                          EXTRACTOR_METATYPE_FILENAME,
+                                          EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
                                           EXTRACTOR_METAFORMAT_UTF8, "text/plain",
                                           ds->pos->short_filename, 
                                           strlen (ds->pos->short_filename) + 1);
index fac478d385d6b588cc1dcd78b7158d7575f06401..50c8785b6623c7fb241021fcf6adc41288146826 100644 (file)
@@ -1805,7 +1805,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
   if (ent > 0)
   {
     full_name = GNUNET_CONTAINER_meta_data_get_first_by_types (md,
-        EXTRACTOR_METATYPE_FILENAME, -1);
+        EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, -1);
     if (NULL != full_name)
     {
       filename = full_name;
index c2ec01c0420506550fe6b0b5a33dfddbe46ebb91..b1051c8b68875421389541d60cc9ee471a7f6ba2 100644 (file)
@@ -315,7 +315,8 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
   i->data = GNUNET_malloc (data_len);
   memcpy (i->data, data, data_len);
   /* change OS native dir separators to unix '/' and others to '_' */
-  if (type == EXTRACTOR_METATYPE_FILENAME)
+  if ( (type == EXTRACTOR_METATYPE_FILENAME) ||
+       (type == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) )
   {
     p = i->data;
     while ((*p != '\0') && (p < i->data + data_len))
index 356a83b6b60f18dd26f92c23470029cd07b0176d..782a405fcf2614526b2c565dba0ffc89b4ee0fd2 100644 (file)
@@ -319,6 +319,7 @@ GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg,
       name =
           GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
                                                          EXTRACTOR_METATYPE_TITLE,
+                                                         EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
                                                          EXTRACTOR_METATYPE_FILENAME,
                                                          EXTRACTOR_METATYPE_DESCRIPTION,
                                                          EXTRACTOR_METATYPE_SUBJECT,
index 1a884bc7557c7fbc3e5c6f25e341ef087684181b..8000a93fb04c3fe677e728998445c11fe5334236 100644 (file)
@@ -607,6 +607,7 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t)
   return ret;
 }
 
+
 /**
  * "man basename"
  * Returns a pointer to a part of filename (allocates nothing)!