test_fs_download \
test_fs_search \
test_fs_start_stop \
+ test_fs_unindex \
test_fs_uri
# $(check_PROGRAMS)
*/
int do_index;
+ /**
+ * Is "file_id" already valid? Set to GNUNET_YES
+ * once the hash has been calculated.
+ */
+ int have_hash;
+
+ /**
+ * Has the service confirmed our INDEX_START request?
+ * GNUNET_YES if this step has been completed.
+ */
+ int index_start_confirmed;
+
} file;
/**
{
struct FileInfo *fi;
struct stat sbuf;
+ struct GNUNET_FS_FileInformation *ret;
if (0 != STAT (filename, &sbuf))
{
}
fi = GNUNET_malloc (sizeof(struct FileInfo));
fi->filename = GNUNET_strdup (filename);
- return GNUNET_FS_file_information_create_from_reader (client_info,
- sbuf.st_size,
- &data_reader_file,
- fi,
- keywords,
- meta,
- do_index,
- anonymity,
- priority,
- expirationTime);
+ ret = GNUNET_FS_file_information_create_from_reader (client_info,
+ sbuf.st_size,
+ &data_reader_file,
+ fi,
+ keywords,
+ meta,
+ do_index,
+ anonymity,
+ priority,
+ expirationTime);
+ ret->data.file.filename = GNUNET_strdup (filename);
+ return ret;
}
struct PutContCtx * dpc_cls;
struct OnDemandBlock odb;
-#if DEBUG_PUBLISH
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Publishing block `%s' for offset %llu with size %u\n",
- GNUNET_h2s (query),
- (unsigned long long) offset,
- (unsigned int) block_size);
-#endif
p = sc->fi_pos;
if (NULL == sc->dsh)
{
dpc_cls->cont_cls = sc;
dpc_cls->sc = sc;
dpc_cls->p = p;
- if ( (p->is_directory) &&
- (p->data.file.do_index) &&
+ if ( (! p->is_directory) &&
+ (GNUNET_YES == p->data.file.do_index) &&
(type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) )
{
+#if DEBUG_PUBLISH
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Indexing block `%s' for offset %llu with index size %u\n",
+ GNUNET_h2s (query),
+ (unsigned long long) offset,
+ sizeof (struct OnDemandBlock));
+#endif
odb.offset = offset;
odb.file_id = p->data.file.file_id;
GNUNET_DATASTORE_put (sc->dsh,
dpc_cls);
return;
}
+#if DEBUG_PUBLISH
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Publishing block `%s' for offset %llu with size %u\n",
+ GNUNET_h2s (query),
+ (unsigned long long) offset,
+ (unsigned int) block_size);
+#endif
GNUNET_DATASTORE_put (sc->dsh,
sc->rid,
query,
publish_content (sc);
return;
}
+ p->data.file.index_start_confirmed = GNUNET_YES;
/* success! continue with indexing */
publish_content (sc);
}
publish_content (sc);
return;
}
+ if (GNUNET_YES == p->data.file.index_start_confirmed)
+ {
+ publish_content (sc);
+ return;
+ }
slen = strlen (p->data.file.filename) + 1;
if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage))
{
publish_content (sc);
return;
}
+#if DEBUG_PUBLISH
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hash of indexed file `%s' is `%s'\n",
+ p->data.file.filename,
+ GNUNET_h2s (res));
+#endif
client = GNUNET_CLIENT_connect (sc->h->sched,
"fs",
sc->h->cfg);
return;
}
p->data.file.file_id = *res;
+ p->data.file.have_hash = GNUNET_YES;
ism = GNUNET_malloc (sizeof(struct IndexStartMessage) +
slen);
ism->header.size = htons(sizeof(struct IndexStartMessage) +
ism->device = htonl (dev);
ism->inode = GNUNET_htonll(ino);
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to get file identifiers for `%s'\n"),
+ p->data.file.filename);
+ }
+ ism->file_id = *res;
memcpy (&ism[1],
p->data.file.filename,
slen);
publish_content (sc);
return;
}
- GNUNET_CRYPTO_hash_file (sc->h->sched,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- GNUNET_NO,
- p->data.file.filename,
- HASHING_BLOCKSIZE,
- &hash_for_index_cb,
- sc);
+ if (p->data.file.have_hash)
+ hash_for_index_cb (sc,
+ &p->data.file.file_id);
+ else
+ GNUNET_CRYPTO_hash_file (sc->h->sched,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ GNUNET_NO,
+ p->data.file.filename,
+ HASHING_BLOCKSIZE,
+ &hash_for_index_cb,
+ sc);
return;
}
publish_content (sc);
/**
* @file fs/fs_unindex.c
- * @author Krista Bennett
+ * @author Krista Grothoff
* @author Christian Grothoff
* @brief Unindex file.
- *
- * TODO:
- * - code cleanup (share more with upload.c)
*/
#include "platform.h"
#include "gnunet_constants.h"
sizeof(GNUNET_HashCode))) )
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Hash mismatch trying to index file `%s'\n"),
- ii->filename);
+ _("Hash mismatch trying to index file `%s' which has hash `%s'\n"),
+ ii->filename,
+ GNUNET_h2s (res));
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Wanted `%s'\n",
+ GNUNET_h2s (&ii->file_id));
+#endif
GNUNET_SERVER_transmit_context_append (ii->tc,
NULL, 0,
GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED);
signal_index_ok (ii);
return;
}
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
+ (unsigned long long) ino,
+ (unsigned long long) myino,
+ (unsigned int) dev,
+ (unsigned int) mydev);
+#endif
/* slow validation, need to hash full file (again) */
GNUNET_CRYPTO_hash_file (sched,
GNUNET_SCHEDULER_PRIORITY_IDLE,
}
pos = next;
}
- if (GNUNET_YES == found)
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client requested unindexing of file `%s': %s\n",
+ GNUNET_h2s (&um->file_id),
+ found ? "found" : "not found");
+#endif
+ if (GNUNET_YES == found)
write_index_list ();
tc = GNUNET_SERVER_transmit_context_create (client);
GNUNET_SERVER_transmit_context_append (tc,
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
printf ("Publishing complete, %llu kbps.\n",
(unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
- fn = GNUNET_DISK_mktemp ("gnunet-download-test-dstXXXXXX");
+ fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
start = GNUNET_TIME_absolute_get ();
download = GNUNET_FS_download_start (fs,
event->value.publish.specifics.completed.chk_uri,
#include "gnunet_arm_service.h"
#include "gnunet_fs_service.h"
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
#define START_ARM GNUNET_YES
sched = s;
setup_peer (&p1, "test_fs_unindex_data.conf");
- fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dstXXXXXX");
+ fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
fs = GNUNET_FS_start (sched,
cfg,
"test-fs-unindex",