From c35923b467c9dbed452c24bb6af3b859f5238e95 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 12 Sep 2011 20:51:01 +0300 Subject: [PATCH] * mu-store-write.cc: cleaunp --- src/mu-store-write.cc | 45 +++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/mu-store-write.cc b/src/mu-store-write.cc index f1a22d01..fc0100e0 100644 --- a/src/mu-store-write.cc +++ b/src/mu-store-write.cc @@ -557,11 +557,12 @@ each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc) } -gboolean -mu_store_store_msg (MuStore *store, MuMsg *msg, gboolean replace) +unsigned +mu_store_add_msg (MuStore *store, MuMsg *msg, gboolean replace, + GError **err) { - g_return_val_if_fail (store, FALSE); - g_return_val_if_fail (msg, FALSE); + g_return_val_if_fail (store, MU_STORE_INVALID_DOCID); + g_return_val_if_fail (msg, MU_STORE_INVALID_DOCID); try { Xapian::Document newdoc; @@ -595,49 +596,35 @@ mu_store_store_msg (MuStore *store, MuMsg *msg, gboolean replace) if (store->inc_processed() % store->batch_size() == 0) store->commit_transaction(); - return TRUE; + return id; - } MU_XAPIAN_CATCH_BLOCK; + } MU_XAPIAN_CATCH_BLOCK_G_ERROR (err, MU_ERROR_XAPIAN_STORE_FAILED); if (store->in_transaction()) store->rollback_transaction(); - return FALSE; + return MU_STORE_INVALID_DOCID; } -/* FIXME: use GError */ -gboolean -mu_store_store_path (MuStore *store, const char *path) +unsigned +mu_store_add_path (MuStore *store, const char *path, GError **err) { MuMsg *msg; - GError *err; - gboolean rv; + unsigned docid; g_return_val_if_fail (store, FALSE); g_return_val_if_fail (path, FALSE); err = NULL; - msg = mu_msg_new_from_file (path, NULL, &err); - - if (!msg) { - if (err) { - g_warning ("failed to create message %s to store: %s", - path, err->message); - g_error_free (err); - } else - g_warning ("failed to create message %s to store", path); - - return FALSE; - } - - rv = mu_store_store_msg (store, msg, TRUE); - if (!rv) - g_warning ("failed to store %s", path); + msg = mu_msg_new_from_file (path, NULL, err); + if (!msg) + return MU_STORE_INVALID_DOCID; + docid = mu_store_add_msg (store, msg, TRUE, err); mu_msg_unref (msg); - return rv; + return docid; }