fixing bug to ensure that we properly descend into deep directories for the various...
authorChristian Grothoff <christian@grothoff.org>
Wed, 11 Jan 2012 21:11:51 +0000 (21:11 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 11 Jan 2012 21:11:51 +0000 (21:11 +0000)
src/fs/fs_api.c
src/fs/fs_api.h
src/fs/fs_publish.c

index 2b1e51031137f11c89b34100ab50da51681e95d2..3c0d5bc7248677f3e6967ba09270ff65fd4619be 100644 (file)
@@ -1243,13 +1243,24 @@ fip_signal_resume (void *cls, struct GNUNET_FS_FileInformation *fi,
                    struct GNUNET_FS_BlockOptions *bo, int *do_index,
                    void **client_info)
 {
-  struct GNUNET_FS_PublishContext *sc = cls;
+  struct GNUNET_FS_PublishContext *pc = cls;
   struct GNUNET_FS_ProgressInfo pi;
 
+  if (GNUNET_YES == pc->skip_next_fi_callback)
+  {
+    pc->skip_next_fi_callback = GNUNET_NO;
+    return GNUNET_OK;
+  }
   pi.status = GNUNET_FS_STATUS_PUBLISH_RESUME;
-  pi.value.publish.specifics.resume.message = sc->fi->emsg;
-  pi.value.publish.specifics.resume.chk_uri = sc->fi->chk_uri;
-  *client_info = GNUNET_FS_publish_make_status_ (&pi, sc, fi, 0);
+  pi.value.publish.specifics.resume.message = pc->fi->emsg;
+  pi.value.publish.specifics.resume.chk_uri = pc->fi->chk_uri;
+  *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0);
+  if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta))
+  {
+    /* process entries in directory */
+    pc->skip_next_fi_callback = GNUNET_YES;
+    GNUNET_FS_file_information_inspect (fi, &fip_signal_resume, pc);
+  }
   return GNUNET_OK;
 }
 
index 4f3781d01049919b52501f70ecd83773d7288fb3..42daa7bc24174968b9a010ff203cfcce255de0e6 100644 (file)
@@ -1203,6 +1203,13 @@ struct GNUNET_FS_PublishContext
    * 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
+   * is for the directory which was already processed with the parent.
+   */
+  int skip_next_fi_callback;
 };
 
 
index 05f66745195020e2eb1ad72242b0d7021a4cd152..4ae3264a21bd38f5aa93b83189a28f1a10207ba7 100644 (file)
@@ -954,6 +954,11 @@ fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi,
   unsigned int kc;
   uint64_t left;
 
+  if (GNUNET_YES == pc->skip_next_fi_callback)
+  {
+    pc->skip_next_fi_callback = GNUNET_NO;
+    return GNUNET_OK;
+  }
 #if DEBUG_PUBLISH
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting publish operation\n");
 #endif
@@ -991,6 +996,12 @@ fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi,
   pi.status = GNUNET_FS_STATUS_PUBLISH_START;
   *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0);
   GNUNET_FS_file_information_sync_ (fi);
+  if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta))
+  {
+    /* process entries in directory */
+    pc->skip_next_fi_callback = GNUNET_YES;
+    GNUNET_FS_file_information_inspect (fi, &fip_signal_start, pc);
+  }
   return GNUNET_OK;
 }
 
@@ -1020,6 +1031,17 @@ fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi,
   struct GNUNET_FS_ProgressInfo pi;
   uint64_t off;
 
+  if (GNUNET_YES == pc->skip_next_fi_callback)
+  {
+    pc->skip_next_fi_callback = GNUNET_NO;
+    return GNUNET_OK;
+  }
+  if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta))
+  {
+    /* process entries in directory */
+    pc->skip_next_fi_callback = GNUNET_YES;
+    GNUNET_FS_file_information_inspect (fi, &fip_signal_suspend, pc);
+  }
 #if DEBUG_PUBLISH
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending publish operation\n");
 #endif
@@ -1204,6 +1226,17 @@ fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi,
   struct GNUNET_FS_ProgressInfo pi;
   uint64_t off;
 
+  if (GNUNET_YES == pc->skip_next_fi_callback)
+  {
+    pc->skip_next_fi_callback = GNUNET_NO;
+    return GNUNET_OK;
+  }
+  if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta))
+  {
+    /* process entries in directory first */
+    pc->skip_next_fi_callback = GNUNET_YES;
+    GNUNET_FS_file_information_inspect (fi, &fip_signal_stop, pc);
+  }
   if (fi->serialization != NULL)
   {
     GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO,