arg
[oweals/gnunet.git] / src / fs / fs_unindex.c
index 38e1073f0a3735a263a30f67602396a11b426e1a..c4360a82dcc788b1b769b1b3d695f79d01983478 100644 (file)
@@ -31,6 +31,7 @@
 #include "fs.h"
 #include "fs_tree.h"
 
+#define DEBUG_UNINDEX GNUNET_NO
 
 /**
  * Function called by the tree encoder to obtain
@@ -113,7 +114,7 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
  * @param offset where are we in the file
  * @param pt_block plaintext of the currently processed block
  * @param pt_size size of pt_block
- * @param depth depth of the block in the tree
+ * @param depth depth of the block in the tree, 0 for DBLOCK
  */
 static void
 unindex_progress (void *cls,
@@ -172,6 +173,10 @@ process_cont (void *cls,
       signal_unindex_error (uc);
       return;
     }  
+#if DEBUG_UNINDEX
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Datastore REMOVE operation succeeded\n");
+#endif
   GNUNET_FS_tree_encoder_next (uc->tc);
 }
 
@@ -183,16 +188,18 @@ process_cont (void *cls,
  * or (on error) "GNUNET_FS_tree_encode_finish".
  *
  * @param cls closure
- * @param query the query for the block (key for lookup in the datastore)
+ * @param chk content hash key for the block (key for lookup in the datastore)
  * @param offset offset of the block
+ * @param depth depth of the block, 0 for DBLOCK
  * @param type type of the block (IBLOCK or DBLOCK)
  * @param block the (encrypted) block
  * @param block_size size of block (in bytes)
  */
 static void 
 unindex_process (void *cls,
-                const GNUNET_HashCode *query,
+                const struct ContentHashKey *chk,
                 uint64_t offset,
+                unsigned int depth,
                 enum GNUNET_BLOCK_Type type,
                 const void *block,
                 uint16_t block_size)
@@ -202,7 +209,7 @@ unindex_process (void *cls,
   const void *data;
   struct OnDemandBlock odb;
 
-  if (type != GNUNET_BLOCK_TYPE_DBLOCK)
+  if (type != GNUNET_BLOCK_TYPE_FS_DBLOCK)
     {
       size = block_size;
       data = block;
@@ -214,8 +221,12 @@ unindex_process (void *cls,
       odb.file_id = uc->file_id;
       data = &odb;
     }
+#if DEBUG_UNINDEX
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Sending REMOVE request to DATASTORE service\n");
+#endif
   GNUNET_DATASTORE_remove (uc->dsh,
-                          query,
+                          &chk->query,
                           size,
                           data,
                           -2, 1,
@@ -309,8 +320,7 @@ unindex_finish (void *cls,
   uc->dsh = NULL;
   uc->state = UNINDEX_STATE_FS_NOTIFY;
   GNUNET_FS_unindex_sync_ (uc);
-  uc->client = GNUNET_CLIENT_connect (uc->h->sched,
-                                     "fs",
+  uc->client = GNUNET_CLIENT_connect ("fs",
                                      uc->h->cfg);
   if (uc->client == NULL)
     {
@@ -320,6 +330,10 @@ unindex_finish (void *cls,
       signal_unindex_error (uc);
       return;
     }
+#if DEBUG_UNINDEX
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Sending UNINDEX message to FS service\n");
+#endif
   req.header.size = htons (sizeof (struct UnindexMessage));
   req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX);
   req.reserved = 0;
@@ -342,8 +356,7 @@ unindex_finish (void *cls,
 void 
 GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
 {
-  uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg,
-                                     uc->h->sched);
+  uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
   if (NULL == uc->dsh)
     {
       uc->state = UNINDEX_STATE_ERROR;
@@ -493,8 +506,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
   pi.status = GNUNET_FS_STATUS_UNINDEX_START;
   pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
   GNUNET_FS_unindex_make_status_ (&pi, ret, 0);
-  ret->fhc = GNUNET_CRYPTO_hash_file (h->sched,
-                                     GNUNET_SCHEDULER_PRIORITY_IDLE,
+  ret->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE,
                                      filename,
                                      HASHING_BLOCKSIZE,
                                      &GNUNET_FS_unindex_process_hash_,