fix
[oweals/gnunet.git] / src / fs / gnunet-service-fs_indexing.c
index 6c44f8e2f2e979afe26478c22315b2af4a5cad7f..d6654bcdcf21055e6b44e3f6b182c0e2747df66d 100644 (file)
@@ -206,7 +206,6 @@ read_index_list ()
       GNUNET_free (fn);
       return;
     }
-
   while ( (GNUNET_OK ==
           GNUNET_BIO_read (rh,
                            "Hash of indexed file",
@@ -359,6 +358,12 @@ GNUNET_FS_handle_index_start (void *cls,
     }
   ism = (const struct IndexStartMessage*) message;
   fn = GNUNET_STRINGS_filename_expand ((const char*) &ism[1]);
+  if (fn == NULL)
+    {
+      GNUNET_SERVER_receive_done (client,
+                                 GNUNET_SYSERR);
+      return;
+    }
   dev = ntohl (ism->device);
   ino = GNUNET_ntohll (ism->inode);
   ism = (const struct IndexStartMessage*) message;
@@ -367,6 +372,13 @@ GNUNET_FS_handle_index_start (void *cls,
   ii->filename = (const char*) &ii[1];
   memcpy (&ii[1], fn, slen);
   ii->file_id = ism->file_id;  
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received `%s' message for file `%s'\n",
+             "START_INDEX",
+             ii->filename);
+#endif
+
   ii->tc = GNUNET_SERVER_transmit_context_create (client);
   mydev = 0;
   myino = 0;
@@ -471,7 +483,7 @@ GNUNET_FS_handle_unindex (void *cls,
   struct IndexInfo *next;
   struct GNUNET_SERVER_TransmitContext *tc;
   int found;
-  
+
   um = (const struct UnindexMessage*) message;
   found = GNUNET_NO;
   prev = NULL;
@@ -487,6 +499,10 @@ GNUNET_FS_handle_unindex (void *cls,
            indexed_files = next;
          else
            prev->next = next;
+         GNUNET_break (GNUNET_OK ==
+                       GNUNET_CONTAINER_multihashmap_remove (ifm,
+                                                             &pos->file_id,
+                                                             (void*) pos->filename));
          GNUNET_free (pos);
          found = GNUNET_YES;
        }
@@ -610,10 +626,11 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
                                        sizeof (ndata)))) )
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 _("Could not access indexed file `%s' at offset %llu: %s\n"),
+                 _("Could not access indexed file `%s' (%s) at offset %llu: %s\n"),
                  GNUNET_h2s (&odb->file_id),
+                 fn,
                  (unsigned long long) off,
-                 STRERROR (errno));
+                 (fn == NULL) ? _("not indexed") : STRERROR (errno));
       if (fh != NULL)
        GNUNET_DISK_file_close (fh);
       GNUNET_DATASTORE_remove (dsh,