diff options
Diffstat (limited to 'worker/notmuch/lib')
-rw-r--r-- | worker/notmuch/lib/database.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go index 178a2f4f..c3c92b7f 100644 --- a/worker/notmuch/lib/database.go +++ b/worker/notmuch/lib/database.go @@ -120,6 +120,22 @@ func (db *DB) newQuery(ndb *notmuch.DB, query string) (*notmuch.Query, error) { return q, nil } +func (db *DB) MsgIDFromFilename(filename string) (string, error) { + var key string + + err := db.withConnection(false, func(ndb *notmuch.DB) error { + msg, err := ndb.FindMessageByFilename(filename) + if err != nil && !errors.Is(err, notmuch.ErrDuplicateMessageID) { + return err + } + defer msg.Close() + key = msg.ID() + return nil + }) + + return key, err +} + func (db *DB) MsgIDsFromQuery(q string) ([]string, error) { var msgIDs []string err := db.withConnection(false, func(ndb *notmuch.DB) error { |