static struct GNUNET_FS_Handle *ctx;
+static struct GNUNET_SCHEDULER_Handle *sched;
+
static struct GNUNET_FS_PublishContext *pc;
static struct GNUNET_CONTAINER_MetaData *meta;
static int do_disable_creation_time;
+static void
+do_stop_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_FS_PublishContext *p;
+
+ if (pc != NULL)
+ {
+ p = pc;
+ pc = NULL;
+ GNUNET_FS_publish_stop (p);
+ }
+}
+
+
/**
* Called by FS client to give information about the progress of an
* operation.
fprintf (stderr,
_("Error publishing: %s.\n"),
info->value.publish.specifics.error.message);
- GNUNET_FS_publish_stop (pc);
+ GNUNET_SCHEDULER_add_continuation (sched,
+ &do_stop_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
fprintf (stdout,
_("Publishing `%s' done.\n"),
info->value.publish.filename);
if (info->value.publish.pctx == NULL)
- GNUNET_FS_publish_stop (pc);
+ GNUNET_SCHEDULER_add_continuation (sched,
+ &do_stop_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
- if (info->value.publish.sc == pc)
- GNUNET_FS_stop (ctx);
+ GNUNET_break (NULL == pc);
return NULL;
default:
fprintf (stderr,
/**
- * Function called on all entries before the
- * publication. This is where we perform
- * modifications to the default based on
- * command-line options.
+ * Function called on all entries before the publication. This is
+ * where we perform modifications to the default based on command-line
+ * options.
*
* @param cls closure
* @param fi the entry in the publish-structure
char *fs;
struct GNUNET_FS_Uri *new_uri;
- if (! do_disable_creation_time)
- GNUNET_CONTAINER_meta_data_add_publication_date (meta);
if (NULL != topKeywords)
{
- new_uri = GNUNET_FS_uri_ksk_merge (topKeywords,
- *uri);
- GNUNET_FS_uri_destroy (*uri);
- *uri = new_uri;
- GNUNET_FS_uri_destroy (topKeywords);
+ if (*uri != NULL)
+ {
+ new_uri = GNUNET_FS_uri_ksk_merge (topKeywords,
+ *uri);
+ GNUNET_FS_uri_destroy (*uri);
+ *uri = new_uri;
+ GNUNET_FS_uri_destroy (topKeywords);
+ }
+ else
+ {
+ *uri = topKeywords;
+ }
topKeywords = NULL;
}
- if (NULL != meta)
+ if (NULL != meta)
{
GNUNET_CONTAINER_meta_data_iterate (meta,
&meta_merger,
GNUNET_CONTAINER_meta_data_destroy (meta);
meta = NULL;
}
+ if (! do_disable_creation_time)
+ GNUNET_CONTAINER_meta_data_add_publication_date (m);
if (extract_only)
{
- fn = GNUNET_CONTAINER_meta_data_get_by_type (meta,
+ fn = GNUNET_CONTAINER_meta_data_get_by_type (m,
EXTRACTOR_METATYPE_FILENAME);
fs = GNUNET_STRINGS_byte_size_fancy (length);
fprintf (stdout,
fs);
GNUNET_free (fn);
GNUNET_free (fs);
- GNUNET_CONTAINER_meta_data_iterate (meta,
+ GNUNET_CONTAINER_meta_data_iterate (m,
&meta_printer,
NULL);
fprintf (stdout, "\n");
}
- if (GNUNET_FS_meta_data_test_for_directory (meta))
+ if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m))
GNUNET_FS_file_information_inspect (fi,
&publish_inspector,
NULL);
* Main function that will be run by the scheduler.
*
* @param cls closure
- * @param sched the scheduler to use
+ * @param s the scheduler to use
* @param args remaining command-line arguments
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
* @param c configuration
*/
static void
run (void *cls,
- struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_SCHEDULER_Handle *s,
char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
struct GNUNET_FS_FileInformation *fi;
struct GNUNET_FS_Namespace *namespace;
struct EXTRACTOR_PluginList *l;
+ struct stat sbuf;
char *ex;
char *emsg;
+ sched = s;
/* check arguments */
if ( ( (uri_string == NULL) || (extract_only) )
&& ( (args[0] == NULL) || (args[1] != NULL) ) )
GNUNET_free (ex);
}
}
- fi = GNUNET_FS_file_information_create_from_directory (NULL,
- args[0],
- &GNUNET_FS_directory_scanner_default,
- l,
- !do_insert,
- anonymity,
- priority,
- GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
- &emsg);
+ emsg = NULL;
+ if (0 != STAT (args[0], &sbuf))
+ GNUNET_asprintf (&emsg,
+ _("Could not access file: %s\n"),
+ STRERROR (errno));
+ else if (S_ISDIR (sbuf.st_mode))
+ fi = GNUNET_FS_file_information_create_from_directory (NULL,
+ args[0],
+ &GNUNET_FS_directory_scanner_default,
+ l,
+ !do_insert,
+ anonymity,
+ priority,
+ GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
+ &emsg);
+ else
+ {
+ fi = GNUNET_FS_file_information_create_from_file (NULL,
+ args[0],
+ NULL,
+ NULL,
+ !do_insert,
+ anonymity,
+ priority,
+ GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
+ GNUNET_break (fi != NULL);
+ }
EXTRACTOR_plugin_remove_all (l);
if (fi == NULL)
{