* @file fs/gnunet-service-fs_indexing.c
* @brief program that provides indexing functions of the file-sharing service
* @author Christian Grothoff
- *
- * TODO:
- * - indexed files/blocks not removed on errors
*/
#include "platform.h"
#include <float.h>
#include "gnunet-service-fs_indexing.h"
#include "fs.h"
-#define DEBUG_FS GNUNET_NO
-
+#define DEBUG_FS GNUNET_YES
/**
* In-memory information about indexed files (also available
/**
* Our configuration.
*/
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
}
if (GNUNET_NO == GNUNET_DISK_file_test (fn))
{
- /* no index info yet */
+ /* no index info yet */
GNUNET_free (fn);
return;
}
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Index request received for file `%s' is indexed as `%s'. Permitting anyway.\n"),
+ _("Index request received for file `%s' is already indexed as `%s'. Permitting anyway.\n"),
ii->filename,
(const char*) GNUNET_CONTAINER_multihashmap_get (ifm,
&ii->file_id));
const struct GNUNET_MessageHeader *message)
{
const struct IndexStartMessage *ism;
- const char *fn;
+ char *fn;
uint16_t msize;
struct IndexInfo *ii;
size_t slen;
return;
}
ism = (const struct IndexStartMessage*) message;
- fn = (const char*) &ism[1];
+ fn = GNUNET_STRINGS_filename_expand ((const char*) &ism[1]);
dev = ntohl (ism->device);
ino = GNUNET_ntohll (ism->inode);
ism = (const struct IndexStartMessage*) message;
memcpy (&ii[1], fn, slen);
ii->file_id = ism->file_id;
ii->tc = GNUNET_SERVER_transmit_context_create (client);
+ mydev = 0;
+ myino = 0;
if ( ( (dev != 0) ||
(ino != 0) ) &&
(GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn,
{
/* fast validation OK! */
signal_index_ok (ii);
+ GNUNET_free (fn);
return;
}
#if DEBUG_FS
HASHING_BLOCKSIZE,
&hash_for_index_val,
ii);
+ GNUNET_free (fn);
}
STRERROR (errno));
if (fh != NULL)
GNUNET_DISK_file_close (fh);
- /* FIXME: if this happens often, we need
- to remove the OnDemand block from the DS! */
+ GNUNET_FS_drq_remove (key,
+ size,
+ data,
+ &remove_cont,
+ NULL,
+ GNUNET_TIME_UNIT_FOREVER_REL);
return GNUNET_SYSERR;
}
GNUNET_DISK_file_close (fh);
_("Indexed file `%s' changed at offset %llu\n"),
fn,
(unsigned long long) off);
- /* FIXME: if this happens often, we need
- to remove the OnDemand block from the DS! */
+ GNUNET_FS_drq_remove (key,
+ size,
+ data,
+ &remove_cont,
+ NULL,
+ GNUNET_TIME_UNIT_FOREVER_REL);
return GNUNET_SYSERR;
}
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "On-demand encoded block for query `%s'\n",
+ GNUNET_h2s (key));
+#endif
cont (cont_cls,
key,
nsize,