* @param ext component of the path
* @param ent entity identifier
*/
-static void
-remove_sync_file (struct GNUNET_FS_Handle *h,
- const char *ext,
- const char *ent)
+void
+GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
+ const char *ext,
+ const char *ent)
{
char *filename;
pc = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishContext));
pc->h = h;
+ pc->serialization = get_serialization_short_name (filename);
fi_root = NULL;
fi_pos = NULL;
ns = NULL;
pc->fi_pos = pc->fi;
}
}
- pc->serialization = get_serialization_short_name (filename);
/* generate RESUME event(s) */
GNUNET_FS_file_information_inspect (pc->fi,
&fip_signal_resume,
GNUNET_BIO_read_close (rh, &emsg))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to resume publishing operation `%s': %s\n"),
+ _("Failure while resuming publishing operation `%s': %s\n"),
filename,
emsg);
GNUNET_free (emsg);
}
if (pc->fi != NULL)
GNUNET_FS_file_information_destroy (pc->fi, NULL, NULL);
- remove_sync_file (h, "publish", pc->serialization);
+ if (pc->serialization != NULL)
+ GNUNET_FS_remove_sync_file_ (h, "publish", pc->serialization);
GNUNET_free_non_null (pc->serialization);
GNUNET_free (pc);
return GNUNET_OK;
GNUNET_BIO_write_string (wh, (pc->namespace == NULL) ? NULL : pc->namespace->name)) )
{
(void) GNUNET_BIO_write_close (wh);
- remove_sync_file (pc->h, "publish", pc->serialization);
+ GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization);
GNUNET_free (pc->serialization);
pc->serialization = NULL;
return;
if (GNUNET_OK !=
GNUNET_BIO_write_close (wh))
{
- remove_sync_file (pc->h, "publish", pc->serialization);
+ GNUNET_FS_remove_sync_file_ (pc->h, "publish", pc->serialization);
GNUNET_free (pc->serialization);
pc->serialization = NULL;
return;
}
+
+
+/**
+ * Function called with a filename of serialized unindexing operation
+ * to deserialize.
+ *
+ * @param cls the 'struct GNUNET_FS_Handle*'
+ * @param filename complete filename (absolute path)
+ * @return GNUNET_OK (continue to iterate)
+ */
+static int
+deserialize_unindex_file (void *cls,
+ const char *filename)
+{
+ struct GNUNET_FS_Handle *h = cls;
+ struct GNUNET_BIO_ReadHandle *rh;
+ struct GNUNET_FS_UnindexContext *uc;
+ char *emsg;
+
+ uc = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext));
+ uc->h = h;
+ uc->serialization = get_serialization_short_name (filename);
+ rh = GNUNET_BIO_read_open (filename);
+ if (rh == NULL)
+ goto cleanup;
+ /* FIXME: do unindex state here! */
+#if 0
+ if ( (GNUNET_OK !=
+ GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_read_int32 (rh, &options)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_read_int32 (rh, &all_done)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) ||
+ (GNUNET_OK !=
+ GNUNET_BIO_read_string (rh, "publish-ns", &ns, 1024)) )
+ goto cleanup;
+ pc->options = options;
+ pc->all_done = all_done;
+ pc->fi = deserialize_file_information (h, fi_root);
+ if (pc->fi == NULL)
+ goto cleanup;
+#endif
+ /* FIXME: generate RESUME event */
+ /* FIXME: re-start unindexing (if needed)... */
+ switch (uc->state)
+ {
+ default:
+ break;
+ }
+ if (GNUNET_OK !=
+ GNUNET_BIO_read_close (rh, &emsg))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failure while resuming unindexing operation `%s': %s\n"),
+ filename,
+ emsg);
+ GNUNET_free (emsg);
+ rh = NULL;
+ goto cleanup;
+ }
+ return GNUNET_OK;
+ cleanup:
+ /* FIXME: clean unindex state here! */
+#if 0
+ GNUNET_free_non_null (pc->nid);
+ GNUNET_free_non_null (pc->nuid);
+ GNUNET_free_non_null (fi_root);
+ GNUNET_free_non_null (ns);
+#endif
+ if ( (rh != NULL) &&
+ (GNUNET_OK !=
+ GNUNET_BIO_read_close (rh, &emsg)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to resume unindexing operation `%s': %s\n"),
+ filename,
+ emsg);
+ GNUNET_free (emsg);
+ }
+ if (uc->serialization != NULL)
+ GNUNET_FS_remove_sync_file_ (h, "unindex", uc->serialization);
+ GNUNET_free_non_null (uc->serialization);
+ GNUNET_free (uc);
+ return GNUNET_OK;
+}
+
+
+
+
+/**
+ * Deserialize information about pending publish operations.
+ *
+ * @param h master context
+ */
+static void
+deserialize_unindex (struct GNUNET_FS_Handle *h)
+{
+ char *dn;
+
+ dn = get_serialization_file_name (h, "unindex", "");
+ if (dn == NULL)
+ return;
+ GNUNET_DISK_directory_scan (dn, &deserialize_unindex_file, h);
+ GNUNET_free (dn);
+}
+
+
/**
* Setup a connection to the file-sharing service.
*
// * for each directory search result, check for active downloads of contents
// Deserialize Download:
// * always part of search???
- // Deserialize Unindex:
- // * read FNs for unindex with progress offset
+ deserialize_unindex (ret);
}
return ret;
}