* @author Christian Grothoff
*
* TODO:
- * - code-sharing with unindex (write unindex code, clean up new FIXME's)
+ * - code-sharing with unindex (write unindex code)
* - indexing cleanup: unindex on failure (can wait)
* - persistence support (can wait)
* - datastore reservation support (optimization)
* @param pc structure to fill in
* @param sc overall publishing context
* @param p file information for the file being published
+ * @param offset where in the file are we so far
*/
static void
make_publish_status (struct GNUNET_FS_ProgressInfo *pi,
struct GNUNET_FS_PublishContext *sc,
- const struct GNUNET_FS_FileInformation *p)
+ const struct GNUNET_FS_FileInformation *p,
+ uint64_t offset)
{
pi->value.publish.sc = sc;
pi->value.publish.fi = p;
= (NULL == p->dir) ? NULL : p->dir->client_info;
pi->value.publish.size
= (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size;
-#if FIXME
pi->value.publish.eta
= GNUNET_TIME_calculate_eta (p->start_time,
- p->publish_offset,
+ offset,
pi->value.publish.size);
- pi->value.publish.completed = p->publish_offset;
-#endif
+ pi->value.publish.completed = offset;
pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time);
pi->value.publish.anonymity = p->anonymity;
}
msg);
GNUNET_FS_file_information_sync (pcc->p);
pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
- make_publish_status (&pi, pcc->sc, pcc->p);
+ make_publish_status (&pi, pcc->sc, pcc->p, 0);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message = pcc->p->emsg;
pcc->p->client_info
struct GNUNET_FS_ProgressInfo pi;
pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED;
- make_publish_status (&pi, sc, p);
+ make_publish_status (&pi, sc, p, p->chk_uri->data.chk.file_length);
pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO;
pi.value.publish.specifics.completed.chk_uri = p->chk_uri;
p->client_info
p->emsg = GNUNET_strdup (emsg);
pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
- make_publish_status (&pi, sc, p);
+ make_publish_status (&pi, sc, p, 0);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message =emsg;
p->client_info
}
-// FIXME: document
+/**
+ * Function called by the tree encoder to obtain
+ * a block of plaintext data (for the lowest level
+ * of the tree).
+ *
+ * @param cls our publishing context
+ * @param offset identifies which block to get
+ * @param max (maximum) number of bytes to get; returning
+ * fewer will also cause errors
+ * @param buf where to copy the plaintext buffer
+ * @param emsg location to store an error message (on error)
+ * @return number of bytes copied to buf, 0 on error
+ */
static size_t
block_reader (void *cls,
uint64_t offset,
}
-// FIXME: document
+/**
+ * The tree encoder has finished processing a
+ * file. Call it's finish method and deal with
+ * the final result.
+ *
+ * @param cls our publishing context
+ * @param tc scheduler's task context (not used)
+ */
static void
encode_cont (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_free (emsg);
GNUNET_FS_file_information_sync (p);
pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
- make_publish_status (&pi, sc, p);
+ make_publish_status (&pi, sc, p, 0);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message = p->emsg;
p->client_info
p = sc->fi_pos;
pi.status = GNUNET_FS_STATUS_PUBLISH_PROGRESS;
- make_publish_status (&pi, sc, p);
+ make_publish_status (&pi, sc, p, offset);
pi.value.publish.specifics.progress.data = pt_block;
pi.value.publish.specifics.progress.offset = offset;
pi.value.publish.specifics.progress.data_len = pt_size;
- // FIXME: add depth to pi
+ pi.value.publish.specifics.progress.depth = depth;
p->client_info
= sc->h->upcb (sc->h->upcb_cls,
&pi);
* continue with the main task.
*
* @param sc overall upload data
- * @param p specific file or directory for which kblocks
- * should be created
*/
-// FIXME: "p" argument is not needed!
static void
-publish_content (struct GNUNET_FS_PublishContext *sc,
- struct GNUNET_FS_FileInformation *p)
+publish_content (struct GNUNET_FS_PublishContext *sc)
{
+ struct GNUNET_FS_FileInformation *p;
char *emsg;
struct GNUNET_FS_DirectoryBuilder *db;
struct GNUNET_FS_FileInformation *dirpos;
void *raw_data;
uint64_t size;
+ p = sc->fi_pos;
if (NULL == p->te)
{
if (p->is_directory)
p->data.file.filename,
_("timeout on index-start request to `fs' service"));
p->data.file.do_index = GNUNET_NO;
- publish_content (sc, p);
+ publish_content (sc);
return;
}
if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK)
p->data.file.filename,
gettext (emsg));
p->data.file.do_index = GNUNET_NO;
- publish_content (sc, p);
+ publish_content (sc);
return;
}
/* success! continue with indexing */
- publish_content (sc, p);
+ publish_content (sc);
}
p->data.file.filename,
_("failed to compute hash"));
p->data.file.do_index = GNUNET_NO;
- publish_content (sc, p);
+ publish_content (sc);
return;
}
slen = strlen (p->data.file.filename) + 1;
p->data.file.filename,
_("filename too long"));
p->data.file.do_index = GNUNET_NO;
- publish_content (sc, p);
+ publish_content (sc);
return;
}
client = GNUNET_CLIENT_connect (sc->h->sched,
p->data.file.filename,
_("could not connect to `fs' service"));
p->data.file.do_index = GNUNET_NO;
- publish_content (sc, p);
+ publish_content (sc);
return;
}
p->data.file.file_id = *res;
GNUNET_free (fn);
GNUNET_FS_file_information_sync (p);
pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR;
- make_publish_status (&pi, sc, p);
+ make_publish_status (&pi, sc, p, 0);
pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL;
pi.value.publish.specifics.error.message = p->emsg;
p->client_info
_("Can not index file `%s': %s. Will try to insert instead.\n"),
"<no-name>",
_("needs to be an actual file"));
- publish_content (sc, p);
+ publish_content (sc);
return;
}
GNUNET_CRYPTO_hash_file (sc->h->sched,
sc);
return;
}
- publish_content (sc, p);
+ publish_content (sc);
}
struct GNUNET_FS_ProgressInfo pi;
pi.status = GNUNET_FS_STATUS_PUBLISH_START;
- make_publish_status (&pi, sc, fi);
+ make_publish_status (&pi, sc, fi, 0);
*client_info = sc->h->upcb (sc->h->upcb_cls,
&pi);
return GNUNET_OK;
{
struct GNUNET_FS_PublishContext*sc = cls;
struct GNUNET_FS_ProgressInfo pi;
+ uint64_t off;
+ off = (fi->chk_uri == NULL) ? 0 : length;
pi.status = GNUNET_FS_STATUS_PUBLISH_STOPPED;
- make_publish_status (&pi, sc, fi);
+ make_publish_status (&pi, sc, fi, off);
GNUNET_break (NULL ==
sc->h->upcb (sc->h->upcb_cls,
&pi));