cleaning up FileInformation struct
authorChristian Grothoff <christian@grothoff.org>
Thu, 29 Apr 2010 21:52:48 +0000 (21:52 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 29 Apr 2010 21:52:48 +0000 (21:52 +0000)
src/fs/fs.c
src/fs/fs.h
src/fs/fs_file_information.c
src/fs/fs_publish.c

index f93dd12f86e4e74c05c503005c2721bfd4cd5cd1..fbf5236640584d86c4257665b809b3522d6e7573 100644 (file)
@@ -274,6 +274,22 @@ get_read_handle (struct GNUNET_FS_Handle *h,
 }
 
 
+/**
+ * Using the given serialization filename, try to deserialize
+ * the file-information tree associated with it.
+ *
+ * @param h master context
+ * @param filename name of the file (without directory) with
+ *        the infromation
+ * @return NULL on error
+ */
+static struct GNUNET_FS_FileInformation *
+deserialize_fi_node (struct GNUNET_BIO_ReadHandle *rh)
+{
+  return NULL;
+}
+
+
 /**
  * Using the given serialization filename, try to deserialize
  * the file-information tree associated with it.
@@ -294,10 +310,7 @@ deserialize_file_information (struct GNUNET_FS_Handle *h,
   rh = get_read_handle (h, "publish-fi", filename);
   if (rh == NULL)
     return NULL;
-  
-  ret = NULL;
-  /* FIXME: not implemented! */
-
+  ret = deserialize_fi_node (rh);
   if (GNUNET_OK !=
       GNUNET_BIO_read_close (rh, &emsg))
     {
index 8726deb6efa35cf88ef74f075403bf641a5b1693..f7d4162d6beedfa91d7f8b7d7269c4bd87ea490a 100644 (file)
@@ -348,6 +348,11 @@ struct GNUNET_FS_FileInformation
    */
   char *serialization_name;
 
+  /**
+   * Name of the file or directory (must be an absolute path). 
+   */
+  char *filename;
+
   /**
    * Data describing either the file or the directory.
    */
@@ -370,16 +375,8 @@ struct GNUNET_FS_FileInformation
       void *reader_cls;
 
       /**
-       * Name of the file (must be an absolute path).
-       * Only required for indexing.  FIXME: not yet
-       * initialized!
-       */
-      char *filename;
-
-      /**
-       * If this file is being indexed, this value
-       * is set to the hash over the entire file
-       * (when the indexing process is started). 
+       * If this file is being indexed, this value is set to the hash
+       * over the entire file (when the indexing process is started).
        * Otherwise this field is not used.
        */
       GNUNET_HashCode file_id;
@@ -395,8 +392,8 @@ struct GNUNET_FS_FileInformation
       int do_index;
 
       /**
-       * Is "file_id" already valid?  Set to GNUNET_YES
-       * once the hash has been calculated.
+       * Is "file_id" already valid?  Set to GNUNET_YES once the hash
+       * has been calculated.
        */
       int have_hash;
 
@@ -413,11 +410,6 @@ struct GNUNET_FS_FileInformation
      */
     struct {
       
-      /**
-       * Name of the directory.
-       */
-      char *dirname;
-      
       /**
        * Linked list of entries in the directory.
        */
index d1ab980e338d15a7a134a25ef7939480be72b4ff..8a5360db1af587b25391862f88a66b6b6445d3d4 100644 (file)
@@ -231,7 +231,7 @@ GNUNET_FS_file_information_create_from_file (void *client_info,
                                                       anonymity,
                                                       priority,
                                                       expirationTime);
-  ret->data.file.filename = GNUNET_strdup (filename);
+  ret->filename = GNUNET_strdup (filename);
   fn = filename;
   while (NULL != (ss = strstr (fn,
                               DIR_SEPARATOR_STR)))
@@ -677,7 +677,7 @@ GNUNET_FS_file_information_create_from_directory (void *client_info,
                                     "text/plain",
                                     fn,
                                     strlen (fn) + 1);
-  ret->data.dir.dirname = GNUNET_strdup (filename);
+  ret->filename = GNUNET_strdup (filename);
   GNUNET_FS_file_information_sync (ret);
   return ret;
 }
@@ -845,7 +845,6 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
                 &fi->expirationTime,
                 &fi->client_info);
       GNUNET_free_non_null (fi->data.dir.dir_data);
-      GNUNET_free_non_null (fi->data.dir.dirname);
     }
   else
     {
@@ -863,6 +862,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
                 &fi->expirationTime,
                 &fi->client_info);
     }
+  GNUNET_free_non_null (fi->filename);
   GNUNET_free_non_null (fi->serialization);
   GNUNET_free_non_null (fi->emsg);
   GNUNET_free_non_null (fi->chk_uri);
index f9970e4097a635526200414a068fe94b5197fb0d..973ecd43880aab7c482e9247eb90a635278a0d56 100644 (file)
@@ -92,9 +92,8 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
     = p->client_info;
   pi->value.publish.pctx
     = (NULL == p->dir) ? NULL : p->dir->client_info;
-  pi->value.publish.filename
-    = (p->is_directory) ? p->data.dir.dirname : p->data.file.filename;
-  pi->value.publish.size
+  pi->value.publish.filename = p->filename;
+  pi->value.publish.size 
     = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
   pi->value.publish.eta 
     = GNUNET_TIME_calculate_eta (p->start_time,
@@ -642,7 +641,7 @@ process_index_start_response (void *cls,
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Can not index file `%s': %s.  Will try to insert instead.\n"),
-                 p->data.file.filename,
+                 p->filename,
                  _("timeout on index-start request to `fs' service"));
       p->data.file.do_index = GNUNET_NO;
       publish_content (sc);
@@ -657,7 +656,7 @@ process_index_start_response (void *cls,
        emsg = gettext_noop ("unknown error");
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Can not index file `%s': %s.  Will try to insert instead.\n"),
-                 p->data.file.filename,
+                 p->filename,
                  gettext (emsg));
       p->data.file.do_index = GNUNET_NO;
       publish_content (sc);
@@ -695,7 +694,7 @@ hash_for_index_cb (void *cls,
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Can not index file `%s': %s.  Will try to insert instead.\n"),
-                 p->data.file.filename,
+                 p->filename,
                  _("failed to compute hash"));
       p->data.file.do_index = GNUNET_NO;
       publish_content (sc);
@@ -706,7 +705,7 @@ hash_for_index_cb (void *cls,
       publish_content (sc);
       return;
     }
-  fn = GNUNET_STRINGS_filename_expand (p->data.file.filename);
+  fn = GNUNET_STRINGS_filename_expand (p->filename);
   slen = strlen (fn) + 1;
   if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage))
     {
@@ -732,7 +731,7 @@ hash_for_index_cb (void *cls,
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Can not index file `%s': %s.  Will try to insert instead.\n"),
-                 p->data.file.filename,
+                 p->filename,
                  _("could not connect to `fs' service"));
       p->data.file.do_index = GNUNET_NO;
       publish_content (sc);
@@ -747,7 +746,7 @@ hash_for_index_cb (void *cls,
                           slen);
   ism->header.type = htons(GNUNET_MESSAGE_TYPE_FS_INDEX_START);
   if (GNUNET_OK ==
-      GNUNET_DISK_file_get_identifiers (p->data.file.filename,
+      GNUNET_DISK_file_get_identifiers (p->filename,
                                        &dev,
                                        &ino))
     {
@@ -758,7 +757,7 @@ hash_for_index_cb (void *cls,
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Failed to get file identifiers for `%s'\n"),
-                 p->data.file.filename);
+                 p->filename);
     }
   ism->file_id = *res;
   memcpy (&ism[1],
@@ -871,7 +870,7 @@ GNUNET_FS_publish_main_ (void *cls,
   if ( (!p->is_directory) &&
        (p->data.file.do_index) )
     {
-      if (NULL == p->data.file.filename)
+      if (NULL == p->filename)
        {
          p->data.file.do_index = GNUNET_NO;
          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -889,7 +888,7 @@ GNUNET_FS_publish_main_ (void *cls,
          p->start_time = GNUNET_TIME_absolute_get ();
          GNUNET_CRYPTO_hash_file (sc->h->sched,
                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                  p->data.file.filename,
+                                  p->filename,
                                   HASHING_BLOCKSIZE,
                                   &hash_for_index_cb,
                                   sc);