X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fruby%2Fdatabase.c;h=416eb709f19d231bfdf6460c37a8e2262fad24af;hp=c03d7011f8406931045183a02eeb0d1395eb0107;hb=b10ce6bc23002d48916b1b2f375480e7540e3164;hpb=034102303eb4a2577ea06a453241fed6fe882322 diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index c03d7011..416eb709 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ @@ -291,7 +291,7 @@ notmuch_rb_database_add_message (VALUE self, VALUE pathv) SafeStringValue (pathv); path = RSTRING_PTR (pathv); - ret = notmuch_database_add_message (db, path, &message); + ret = notmuch_database_index_file (db, path, NULL, &message); notmuch_rb_status_raise (ret); return rb_assoc_new (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message), (ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse); @@ -374,6 +374,30 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv) return Qnil; } +/* + * call-seq: DB.get_all_tags() => TAGS + * + * Returns a list of all tags found in the database. + */ +VALUE +notmuch_rb_database_get_all_tags (VALUE self) +{ + notmuch_database_t *db; + notmuch_tags_t *tags; + + Data_Get_Notmuch_Database (self, db); + + tags = notmuch_database_get_all_tags (db); + if (!tags) { + const char *msg = notmuch_database_status_string (db); + if (!msg) + msg = "Unknown notmuch error"; + + rb_raise (notmuch_rb_eBaseError, "%s", msg); + } + return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); +} + /* * call-seq: DB.query(query) => QUERY *