generate progress events when publishing directories (towards fixing #2230)
authorChristian Grothoff <christian@grothoff.org>
Fri, 11 Oct 2013 14:50:07 +0000 (14:50 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 11 Oct 2013 14:50:07 +0000 (14:50 +0000)
17 files changed:
src/fs/fs_api.c
src/fs/fs_api.h
src/fs/fs_publish.c
src/fs/fs_test_lib.c
src/fs/gnunet-daemon-fsprofiler.c
src/fs/gnunet-publish.c
src/fs/test_fs_download.c
src/fs/test_fs_download_persistence.c
src/fs/test_fs_list_indexed.c
src/fs/test_fs_publish.c
src/fs/test_fs_publish_persistence.c
src/fs/test_fs_search.c
src/fs/test_fs_search_persistence.c
src/fs/test_fs_search_probes.c
src/fs/test_fs_unindex.c
src/fs/test_fs_unindex_persistence.c
src/include/gnunet_fs_service.h

index 688bdf282c8b49f660200c86e84cbf441c393593..f076b0991b90fb25da982e5cdf8a664e8edc2614 100644 (file)
@@ -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)) ||
index 4b0965f150f7a224e39f35388a3935e80a97e36e..77e26e1553c7418def8bf44d09108886ec680684 100644 (file)
@@ -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;
index 05645f0ab1135023ad8bdfcf1a4abceb91d1fd9d..2075c5f2b6d0cd5fd9b26b78d0cec9fa49af8dfa 100644 (file)
@@ -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);
index 925e36a8e5e93aec8b8f3f461134004077f98860..3898f798e0b6d395c9284d786d9a6e686191de21 100644 (file)
@@ -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",
index d4c2b1c02efa37a49292069373c009bfc55bd42d..1549972a1cedbcbbe87c0efeeb27888fc256408d 100644 (file)
@@ -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");
index 7f7423ae5e670d6b7ff7d729b2fb0c1c82a3aca3..12d9a6084d9c96d30e55deb6e224926686e8f8da 100644 (file)
@@ -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);
index 52652dbd368f369da583f7030688245d9997c1a3..51f05192e0c83092a2a66cb3ae1d373a085241e2 100644 (file)
@@ -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",
index 7c9c8c2277fe9be941eb27c1561b30758a30d4e4..a9b9980139acf8954a19c83bf1dedb2027579105 100644 (file)
@@ -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 /
index b505e8a18bdcefb031414ca37fa6df5711eb376d..e359bd8ed24206666f818afb3f531623744400d5 100644 (file)
@@ -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",
index 41b4abd26cc7127926f7b2e2696df674757aee15..d80d749de24c69d05d902cf47a6b677459449d82 100644 (file)
@@ -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",
index 5beb1b7e5bf777d54e19d1fa055de5f32143b2e6..8e5e5f53bfbe7d500426a37a515a4bfc5e342a8d 100644 (file)
@@ -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;
index faf8727a6b071d57d570faa846a2cf7dd63bfb11..f525fb474a1114e5c008ee79fc0973fb4b9b4350 100644 (file)
@@ -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 ();
index 76308ecb940893c1dfa840c5f219fd18f287342e..34ea04acad8ff69849fd6944be9a6545414d26fa 100644 (file)
@@ -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 ();
index 969c525c6b1188bc9bbdfc913a34f0633ae7a4c7..beae34763c0d0f2deadea9e6312f168118189780 100644 (file)
@@ -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 ();
index 033195f0ba68b0f466595154e8487d17c598c036..b64762ce6cc0805c5de1b5d10319ea8410024f5b 100644 (file)
@@ -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 /
index f90a01a79914e9c506e3b385a94bd0e1d2e57b01..0da4193ddd5794d20cb46bd4e8f338dc29a75f20 100644 (file)
@@ -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 /
index 3546fdcb773b2a0652bbca2feacd229f8fdc22c1..011087a570cd54ee8868a13cb4d24c7dbcc25b6c 100644 (file)
@@ -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.