From: Christian Grothoff Date: Thu, 29 Apr 2010 21:52:48 +0000 (+0000) Subject: cleaning up FileInformation struct X-Git-Tag: initial-import-from-subversion-38251~21955 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=40d4dff74eaae781fb99cea505457738c4601e47;p=oweals%2Fgnunet.git cleaning up FileInformation struct --- diff --git a/src/fs/fs.c b/src/fs/fs.c index f93dd12f8..fbf523664 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -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)) { diff --git a/src/fs/fs.h b/src/fs/fs.h index 8726deb6e..f7d4162d6 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -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. */ diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index d1ab980e3..8a5360db1 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -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); diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index f9970e409..973ecd438 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -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);