예제 #1
0
static void
encode_alias (GString *g, gpointer bean)
{
	g_string_append_printf(g,
			"\"name\":\"%s\","
			"\"ver\":%"G_GINT64_FORMAT","
			"\"ctime\":%"G_GINT64_FORMAT","
			"\"system_metadata\":\"%s\","
			"\"header\":\"",
			ALIASES_get_alias(bean)->str,
			ALIASES_get_version(bean),
			ALIASES_get_ctime(bean),
			ALIASES_get_mdsys(bean)->str);
	metautils_gba_to_hexgstr(g, ALIASES_get_content_id(bean));
	g_string_append_c(g, '"');
}
예제 #2
0
void
meta2_json_alias_only(GString *gstr, GSList *l)
{
	void code(GString *g, gpointer bean) {
		g_string_append_printf(g,
				"{\"name\":\"%s\","
				"\"ver\":%"G_GINT64_FORMAT","
				"\"ctime\":%"G_GINT64_FORMAT","
				"\"system_metadata\":\"%s\","
				"\"header\":\"",
				ALIASES_get_alias(bean)->str,
				ALIASES_get_version(bean),
				ALIASES_get_ctime(bean),
				ALIASES_get_mdsys(bean)->str);
		metautils_gba_to_hexgstr(g, ALIASES_get_content_id(bean));
		g_string_append(g, "\"}");
	}
	void s3_list_cb(gpointer ignored, gpointer bean)
	{
		(void) ignored;
		if(max > 0) {
			if(DESCR(bean) == &descr_struct_ALIASES) {
				check_alias(bean);
				max--;
				if(0 == max)
					next_marker = g_strdup(ALIASES_get_alias(bean)->str);
			} else {
				_get_cb(obc, bean);
			}
			return;
		}
		if(DESCR(bean) == &descr_struct_ALIASES) {
			truncated = TRUE;
		}
		_bean_clean(bean);
	}
static int
_list_S3(struct gridd_filter_ctx_s *ctx, struct gridd_reply_ctx_s *reply,
		struct list_params_s *lp, GSList *headers)
{
	GError *e = NULL;
	struct meta2_backend_s *m2b = meta2_filter_ctx_get_backend(ctx);
	struct hc_url_s *url = meta2_filter_ctx_get_url(ctx);
	struct on_bean_ctx_s *obc = _on_bean_ctx_init(ctx, reply);
	gboolean truncated = FALSE;
	char *next_marker = NULL;
	gchar **properties = NULL;

	if (lp->maxkeys <= 0)
		lp->maxkeys = OIO_M2V2_LISTRESULT_BATCH;

	GRID_DEBUG("LP H:%d A:%d D:%d prefix:%s marker:%s end:%s max:%"G_GINT64_FORMAT,
			lp->flag_headers, lp->flag_allversion, lp->flag_nodeleted,
			lp->prefix, lp->marker_start, lp->marker_end, lp->maxkeys);

	// XXX the underlying meta2_backend_list_aliases() function MUST
	// return headers before the associated alias.
	gint64 max = lp->maxkeys;
	void s3_list_cb(gpointer ignored, gpointer bean) {
		(void) ignored;
		if (max > 0) {
			if (DESCR(bean) == &descr_struct_ALIASES) {
				_bean_list_cb(&obc->l, bean);
				if (0 == --max)
					next_marker = g_strdup(ALIASES_get_alias(bean)->str);
			} else {
				_bean_list_cb(&obc->l, bean);
			}
		} else {
			if (DESCR(bean) == &descr_struct_ALIASES)
				truncated = TRUE;
			_bean_clean(bean);
		}
	}
	char * _get_real_name(gpointer alias)
	{
		return _is_directory(alias) ?
			g_strconcat(ALIASES_get_alias(alias)->str, "/", NULL)
			: g_strdup(ALIASES_get_alias(alias)->str);
	}