fix
[oweals/gnunet.git] / src / fs / gnunet-service-fs_indexing.c
index 39999be75da521ab4c5e7b29527d85b8f8219f98..d6654bcdcf21055e6b44e3f6b182c0e2747df66d 100644 (file)
@@ -40,7 +40,7 @@
 #include "gnunet-service-fs_indexing.h"
 #include "fs.h"
 
-#define DEBUG_FS GNUNET_YES
+#define DEBUG_FS GNUNET_NO
 
 /**
  * In-memory information about indexed files (also available
@@ -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;
@@ -478,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;
@@ -494,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;
        }
@@ -621,7 +630,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
                  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,