From: Christian Grothoff Date: Fri, 11 Oct 2013 14:50:07 +0000 (+0000) Subject: generate progress events when publishing directories (towards fixing #2230) X-Git-Tag: initial-import-from-subversion-38251~6575 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cd67a970afe36e8a2aa99e48cbe103cc4cc26424;p=oweals%2Fgnunet.git generate progress events when publishing directories (towards fixing #2230) --- diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 688bdf282..f076b0991 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c @@ -284,7 +284,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "AD: %u, MP: %u; %d probes and %d downloads to start, will run again in %s\n", h->active_downloads, - h->max_parallel_requests, + h->max_parallel_requests, num_probes_change, num_downloads_change, GNUNET_STRINGS_relative_time_to_string (restart_at, GNUNET_YES)); @@ -982,6 +982,8 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, case 4: /* directory */ ret->is_directory = GNUNET_YES; if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dsize)) || + (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_completed)) || + (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.dir.contents_size)) || (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) || (GNUNET_OK != GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) || @@ -1335,6 +1337,8 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) (NULL == fi->data.dir.entries->serialization) ) GNUNET_FS_file_information_sync_ (fi->data.dir.entries); if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_completed)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.dir.contents_size)) || (GNUNET_OK != GNUNET_BIO_write (wh, fi->data.dir.dir_data, (uint32_t) fi->data.dir.dir_size)) || diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index 4b0965f15..77e26e155 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h @@ -347,7 +347,7 @@ struct GNUNET_FS_FileInformation /** * Has the service confirmed our INDEX_START request? - * GNUNET_YES if this step has been completed. + * #GNUNET_YES if this step has been completed. */ int index_start_confirmed; @@ -376,6 +376,16 @@ struct GNUNET_FS_FileInformation */ void *dir_data; + /** + * How much of the directory have we published (relative to @e contents_size). + */ + uint64_t contents_completed; + + /** + * Sum of all of the sizes of all of the files in the directory. + */ + uint64_t contents_size; + } dir; } data; @@ -416,17 +426,17 @@ typedef void (*GNUNET_FS_QueueStop) (void *cls); * Priorities for the queue. */ enum GNUNET_FS_QueuePriority - { - /** - * This is a probe (low priority). - */ - GNUNET_FS_QUEUE_PRIORITY_PROBE, +{ + /** + * This is a probe (low priority). + */ + GNUNET_FS_QUEUE_PRIORITY_PROBE, - /** - * Default priority. - */ - GNUNET_FS_QUEUE_PRIORITY_NORMAL - }; + /** + * Default priority. + */ + GNUNET_FS_QUEUE_PRIORITY_NORMAL +}; /** @@ -701,6 +711,7 @@ size_t GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, char **emsg); + /** * Notification of FS that a search probe has made progress. * This function is used INSTEAD of the client's event handler @@ -901,6 +912,7 @@ GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, void GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f); + /** * Synchronize this publishing struct with its mirror * on disk. Note that all internal FS-operations that change @@ -912,6 +924,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f); void GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc); + /** * Synchronize this unindex struct with its mirror * on disk. Note that all internal FS-operations that change @@ -923,6 +936,7 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc); void GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); + /** * Synchronize this search struct with its mirror * on disk. Note that all internal FS-operations that change @@ -934,6 +948,7 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); void GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); + /** * Synchronize this search result with its mirror * on disk. Note that all internal FS-operations that change @@ -945,6 +960,7 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); void GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr); + /** * Synchronize this download struct with its mirror * on disk. Note that all internal FS-operations that change @@ -956,6 +972,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr); void GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc); + /** * Create SUSPEND event for the given publish operation * and then clean up our state (without stop signal). @@ -965,6 +982,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc); void GNUNET_FS_publish_signal_suspend_ (void *cls); + /** * Create SUSPEND event for the given search operation * and then clean up our state (without stop signal). @@ -974,6 +992,7 @@ GNUNET_FS_publish_signal_suspend_ (void *cls); void GNUNET_FS_search_signal_suspend_ (void *cls); + /** * Create SUSPEND event for the given download operation * and then clean up our state (without stop signal). @@ -983,6 +1002,7 @@ GNUNET_FS_search_signal_suspend_ (void *cls); void GNUNET_FS_download_signal_suspend_ (void *cls); + /** * Create SUSPEND event for the given unindex operation * and then clean up our state (without stop signal). @@ -992,6 +1012,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls); void GNUNET_FS_unindex_signal_suspend_ (void *cls); + /** * Function signature of the functions that can be called * to trigger suspend signals and clean-up for top-level @@ -1034,11 +1055,12 @@ struct TopLevelActivity * * @param h global fs handle * @param ssf suspend signal function to use - * @param ssf_cls closure for ssf + * @param ssf_cls closure for @a ssf * @return fresh top-level activity handle */ struct TopLevelActivity * -GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, +GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, + SuspendSignalFunction ssf, void *ssf_cls); @@ -1049,7 +1071,8 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, * @param top top level activity entry */ void -GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, struct TopLevelActivity *top); +GNUNET_FS_end_top (struct GNUNET_FS_Handle *h, + struct TopLevelActivity *top); @@ -1256,13 +1279,13 @@ struct GNUNET_FS_PublishContext int rid; /** - * Set to GNUNET_YES if all processing has completed. + * Set to #GNUNET_YES if all processing has completed. */ int all_done; /** - * Flag set to GNUNET_YES if the next callback from - * GNUNET_FS_file_information_inspect should be skipped because it + * Flag set to #GNUNET_YES if the next callback from + * #GNUNET_FS_file_information_inspect should be skipped because it * is for the directory which was already processed with the parent. */ int skip_next_fi_callback; @@ -1362,7 +1385,7 @@ struct GNUNET_FS_UnindexContext /** * Connection to the FS service, only valid during the - * UNINDEX_STATE_FS_NOTIFY phase. + * #UNINDEX_STATE_FS_NOTIFY phase. */ struct GNUNET_CLIENT_Connection *client; @@ -1424,7 +1447,7 @@ struct GNUNET_FS_UnindexContext uint64_t file_size; /** - * Random offset given to 'GNUNET_DATASTORE_get_key'. + * Random offset given to #GNUNET_DATASTORE_get_key. */ uint64_t roff; @@ -1561,7 +1584,7 @@ struct GNUNET_FS_SearchContext /** * ID of a task that is using this struct and that must be cancelled * when the search is being stopped (if not - * GNUNET_SCHEDULER_NO_TASK). Used for the task that adds some + * #GNUNET_SCHEDULER_NO_TASK). Used for the task that adds some * artificial delay when trying to reconnect to the FS service. */ GNUNET_SCHEDULER_TaskIdentifier task; @@ -1602,65 +1625,65 @@ struct GNUNET_FS_SearchContext */ enum BlockRequestState { - /** - * Initial state, block has only been allocated (since it is - * relevant to the overall download request). - */ + /** + * Initial state, block has only been allocated (since it is + * relevant to the overall download request). + */ BRS_INIT = 0, - /** - * We've checked the block on the path down the tree, and the - * content on disk did match the desired CHK, but not all - * the way down, so at the bottom some blocks will still - * need to be reconstructed). - */ + /** + * We've checked the block on the path down the tree, and the + * content on disk did match the desired CHK, but not all + * the way down, so at the bottom some blocks will still + * need to be reconstructed). + */ BRS_RECONSTRUCT_DOWN = 1, - /** - * We've calculated the CHK bottom-up based on the meta data. - * This may work, but if it did we have to write the meta data to - * disk at the end (and we still need to check against the - * CHK set on top). - */ + /** + * We've calculated the CHK bottom-up based on the meta data. + * This may work, but if it did we have to write the meta data to + * disk at the end (and we still need to check against the + * CHK set on top). + */ BRS_RECONSTRUCT_META_UP = 2, - /** - * We've calculated the CHK bottom-up based on what we have on - * disk, which may not be what the desired CHK is. If the - * reconstructed CHKs match whatever comes from above, we're - * done with the respective subtree. - */ + /** + * We've calculated the CHK bottom-up based on what we have on + * disk, which may not be what the desired CHK is. If the + * reconstructed CHKs match whatever comes from above, we're + * done with the respective subtree. + */ BRS_RECONSTRUCT_UP = 3, - /** - * We've determined the real, desired CHK for this block - * (full tree reconstruction failed), request is now pending. - * If the CHK that bubbled up through reconstruction did match - * the top-level request, the state machine for the subtree - * would have moved to BRS_DOWNLOAD_UP. - */ + /** + * We've determined the real, desired CHK for this block + * (full tree reconstruction failed), request is now pending. + * If the CHK that bubbled up through reconstruction did match + * the top-level request, the state machine for the subtree + * would have moved to BRS_DOWNLOAD_UP. + */ BRS_CHK_SET = 4, - /** - * We've successfully downloaded this block, but the children - * still need to be either downloaded or verified (download - * request propagates down). If the download fails, the - * state machine for this block may move to - * BRS_DOWNLOAD_ERROR instead. - */ + /** + * We've successfully downloaded this block, but the children + * still need to be either downloaded or verified (download + * request propagates down). If the download fails, the + * state machine for this block may move to + * BRS_DOWNLOAD_ERROR instead. + */ BRS_DOWNLOAD_DOWN = 5, - /** - * This block and all of its children have been downloaded - * successfully (full completion propagates up). - */ + /** + * This block and all of its children have been downloaded + * successfully (full completion propagates up). + */ BRS_DOWNLOAD_UP = 6, - /** - * We got a block back that matched the query but did not hash to - * the key (malicious publisher or hash collision); this block - * can never be downloaded (error propagates up). - */ + /** + * We got a block back that matched the query but did not hash to + * the key (malicious publisher or hash collision); this block + * can never be downloaded (error propagates up). + */ BRS_ERROR = 7 }; @@ -1724,7 +1747,7 @@ struct DownloadRequest enum BlockRequestState state; /** - * GNUNET_YES if this entry is in the pending list. + * #GNUNET_YES if this entry is in the pending list. */ int is_pending; @@ -1944,7 +1967,7 @@ struct GNUNET_FS_DownloadContext /** * Flag set upon transitive completion (includes child downloads). - * This flag is only set to GNUNET_YES for directories where all + * This flag is only set to #GNUNET_YES for directories where all * child-downloads have also completed (and signalled completion). */ int has_finished; diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 05645f0ab..2075c5f2b 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -362,7 +362,7 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) if (UINT64_MAX == offset) { if (&GNUNET_FS_data_reader_file_ == p->data.file.reader) - { + { /* force closing the file to avoid keeping too many files open */ p->data.file.reader (p->data.file.reader_cls, offset, 0, NULL, NULL); } @@ -390,7 +390,8 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) * @param tc scheduler's task context (not used) */ static void -encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +encode_cont (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p; @@ -421,7 +422,7 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } else { - /* final progress event */ + /* final progress event */ GNUNET_assert (NULL != p->chk_uri); flen = GNUNET_FS_uri_chk_get_file_size (p->chk_uri); pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS; @@ -454,8 +455,12 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param block_size size of @a block (in bytes) */ static void -block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, - unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, +block_proc (void *cls, + const struct ContentHashKey *chk, + uint64_t offset, + unsigned int depth, + enum GNUNET_BLOCK_Type type, + const void *block, uint16_t block_size) { struct GNUNET_FS_PublishContext *pc = cls; @@ -520,11 +525,14 @@ block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, * @param depth depth of the block in the tree, 0 for DBLOCK */ static void -progress_proc (void *cls, uint64_t offset, const void *pt_block, size_t pt_size, +progress_proc (void *cls, uint64_t offset, + const void *pt_block, + size_t pt_size, unsigned int depth) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p; + struct GNUNET_FS_FileInformation *par; struct GNUNET_FS_ProgressInfo pi; p = pc->fi_pos; @@ -534,6 +542,23 @@ progress_proc (void *cls, uint64_t offset, const void *pt_block, size_t pt_size, pi.value.publish.specifics.progress.data_len = pt_size; pi.value.publish.specifics.progress.depth = depth; p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, offset); + if ( (0 != depth) || + (GNUNET_YES == p->is_directory) ) + return; + while (NULL != (par = p->dir)) + { + p = par; + GNUNET_assert (GNUNET_YES == par->is_directory); + p->data.dir.contents_completed += pt_size; + pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY; + pi.value.publish.specifics.progress_directory.completed = p->data.dir.contents_completed; + pi.value.publish.specifics.progress_directory.total = p->data.dir.contents_size; + pi.value.publish.specifics.progress_directory.eta = GNUNET_TIME_calculate_eta (p->start_time, + p->data.dir.contents_completed, + p->data.dir.contents_size); + p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); + + } } @@ -1136,6 +1161,25 @@ finish_reserve (void *cls, int success, } +/** + * Calculate the total size of all of the files in the directory structure. + * + * @param fi file structure to traverse + */ +static uint64_t +compute_contents_size (struct GNUNET_FS_FileInformation *fi) +{ + struct GNUNET_FS_FileInformation *ent; + + if (GNUNET_YES != fi->is_directory) + return fi->data.file.file_size; + fi->data.dir.contents_size = 0; + for (ent = fi->data.dir.entries; NULL != ent; ent = ent->next) + fi->data.dir.contents_size += compute_contents_size (ent); + return fi->data.dir.contents_size; +} + + /** * Publish a file or directory. * @@ -1161,6 +1205,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, struct GNUNET_DATASTORE_Handle *dsh; GNUNET_assert (NULL != h); + compute_contents_size (fi); if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) { dsh = GNUNET_DATASTORE_connect (h->cfg); diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 925e36a8e..3898f798e 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -253,6 +253,8 @@ publish_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) (unsigned long long) info->value.publish.completed, (unsigned long long) info->value.publish.size); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: if (po->verbose) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n", diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c index d4c2b1c02..1549972a1 100644 --- a/src/fs/gnunet-daemon-fsprofiler.c +++ b/src/fs/gnunet-daemon-fsprofiler.c @@ -385,6 +385,9 @@ progress_cb (void *cls, case GNUNET_FS_STATUS_PUBLISH_PROGRESS: p = info->value.publish.cctx; return p; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + p = info->value.publish.cctx; + return p; case GNUNET_FS_STATUS_PUBLISH_ERROR: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Publishing failed\n"); diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 7f7423ae5..12d9a6084 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -227,12 +227,25 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) { s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta, GNUNET_YES); - FPRINTF (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"), + 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); } break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + if (verbose) + { + s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics.progress_directory.eta, + GNUNET_YES); + FPRINTF (stdout, + _("Publishing `%s' at %llu/%llu (%s remaining)\n"), + info->value.publish.filename, + (unsigned long long) info->value.publish.specifics.progress_directory.completed, + (unsigned long long) info->value.publish.specifics.progress_directory.total, s); + } + break; case GNUNET_FS_STATUS_PUBLISH_ERROR: FPRINTF (stderr, _("Error publishing: %s.\n"), info->value.publish.specifics.error.message); diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 52652dbd3..51f05192e 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -139,6 +139,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: fprintf (stdout, "Publishing complete, %llu kb/s.\n", diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index 7c9c8c227..a9b998013 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c @@ -162,6 +162,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000000LL / diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index b505e8a18..e359bd8ed 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c @@ -115,6 +115,9 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + ret = event->value.publish.cctx; + break; case GNUNET_FS_STATUS_PUBLISH_ERROR: ret = event->value.publish.cctx; FPRINTF (stderr, "Error publishing file: %s\n", diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index 41b4abd26..d80d749de 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c @@ -101,6 +101,9 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + ret = event->value.publish.cctx; + break; case GNUNET_FS_STATUS_PUBLISH_ERROR: ret = event->value.publish.cctx; FPRINTF (stderr, "Error publishing file: %s\n", diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index 5beb1b7e5..8e5e5f53b 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c @@ -145,6 +145,9 @@ progress_cb (void *cls, (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) ) GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + ret = event->value.publish.cctx; + return ret; case GNUNET_FS_STATUS_PUBLISH_PROGRESS: consider_restart (event->status); ret = event->value.publish.cctx; diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c index faf8727a6..f525fb474 100644 --- a/src/fs/test_fs_search.c +++ b/src/fs/test_fs_search.c @@ -59,7 +59,7 @@ static int err; static void abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ +{ if (NULL != publish) { GNUNET_FS_publish_stop (publish); @@ -123,6 +123,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); start = GNUNET_TIME_absolute_get (); diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index 76308ecb9..34ea04aca 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c @@ -160,6 +160,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); start = GNUNET_TIME_absolute_get (); diff --git a/src/fs/test_fs_search_probes.c b/src/fs/test_fs_search_probes.c index 969c525c6..beae34763 100644 --- a/src/fs/test_fs_search_probes.c +++ b/src/fs/test_fs_search_probes.c @@ -122,6 +122,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); start = GNUNET_TIME_absolute_get (); diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index 033195f0b..b64762ce6 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c @@ -90,6 +90,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000000LL / diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index f90a01a79..0da4193dd 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -132,6 +132,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.specifics. progress.offset); break; + case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: + break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000000LL / diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 3546fdcb7..011087a57 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h @@ -685,7 +685,13 @@ enum GNUNET_FS_Status * Notification that the unindexing of this file * was stopped (final event for this action). */ - GNUNET_FS_STATUS_UNINDEX_STOPPED = 36 + GNUNET_FS_STATUS_UNINDEX_STOPPED = 36, + + /** + * Notification that we are making progress sharing a directory. + */ + GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY = 37 + }; @@ -842,6 +848,33 @@ struct GNUNET_FS_ProgressInfo } progress; + /** + * These values are only valid for + * #GNUNET_FS_STATUS_PUBLISH_DIRECTORY_PROGRESS events. + */ + struct + { + + /** + * How far are we along in the overall directory? + */ + uint64_t completed; + + /** + * How big do we estimate the entire directory to be? + */ + uint64_t total; + + /** + * At what time do we expect to finish the upload of the + * CONTENTS of the directory. (The direcory itself will take + * extra time, indicated with the "eta" member at the + * "publish"-level of this struct.) + */ + struct GNUNET_TIME_Relative eta; + + } progress_directory; + /** * These values are only valid for * #GNUNET_FS_STATUS_PUBLISH_RESUME events.