From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id oKl/LCCU7mYAvwAAe85BDQ:P1 (envelope-from ) for ; Sat, 21 Sep 2024 09:38:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id oKl/LCCU7mYAvwAAe85BDQ (envelope-from ) for ; Sat, 21 Sep 2024 11:38:40 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=m0jMKmtR; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1726911520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=zqD3KPpehkAXe6g5PuJZcZgjnMZEjbSi7uepOtu02eo=; b=kZw9MoPy3jO+8NRJfQvzIXrBGk5e0qL1BHHW8Bxkn9tMKWaKVkSanyyt/tGH80tALTBjoq 9VjEkI9oN37cljKgzXvnTqdzeMAkU/ToxyfCy1s14JtVg+h3tnz6O5ErDyOML7bvCphr/A YSqbwjCuIOAjRxMno87nDMYJ6Wh7YJ/rgInnSC9qtWyh80hlyQbH6BYKqVeq6IQ8FdThuO 1Xkgg17R7DvHmprZyJPAjGhJJdcyEAOJFmBwf9k5+FVN3lYnvsMvD7rKrGy2g/GmB/JdZG K/vx/IsYO378Ons158giV1cqukdPgq577FnmLyHLN9nPLnA9bYfSzXDfpp/SnA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=m0jMKmtR; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1726911520; a=rsa-sha256; cv=none; b=gpBxKmXrpCuTsCMf9sFamff9pLySLNeLn4+QTkeiHJ7tAiku4L/oCmh/CcF/serdCXmvQD rOMeIq3Rgm/aCVaW5k9ZNk+mw2N90PQFaHgNX2NQsmkJzR80urhfBTbLTXEX4TmZtGhL5D VZ4YxeSZdGa+0N4Td6vPeDGGqtGCL0kdvuNxKzqTGrwM2YXKSt7r9G4pEvHmrUfBmg51+t pWiEP3DzjBVfY6feJuJlvtIVdbHWeYt6FjAi4Bh2Nqnzcqp6310qmfsmjh7zH6e/X3BcWe +s2Q8XEDxJLl2BGOfGi8nnasuitcmk22oKfomm3VKgCsZX1/jZX5pANt9QFpmw== Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5D1869110 for ; Sat, 21 Sep 2024 11:38:40 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7D8585F827; Sat, 21 Sep 2024 09:38:37 +0000 (UTC) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by mail.notmuchmail.org (Postfix) with ESMTPS id 1E7CA5E527 for ; Sat, 21 Sep 2024 09:38:35 +0000 (UTC) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a8b155b5e9eso384987166b.1 for ; Sat, 21 Sep 2024 02:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726911514; x=1727516314; darn=notmuchmail.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0XRmMeXEe5yP0mGWkSfifMav5MsQOEkLLReI4uKemqQ=; b=m0jMKmtRE53oXO+YOZqSdbwS9075UfRZ7+d0sdLkmCDolrGgKdn4l5ykA6shoCmdGH P67YkR7WAkvGJgzwW9c6ZPrRTO5YlfxlWns4aMITTQ4BcDoe5YpspmYN65m4JB/vBsdN xPP2VjhUaSwdcba8bZ4Sz96i/E96gmeqwZhuDdlKB/25eDaS/pDPPO8aEE3tkML49wGh QSK8meOzHYU5YKeLRVZGr5y5tv4vz8XcKfFccdx5oyO9LTp8pBO0QEbyIbrDIVV8pb+L g9BKhbz/HiTR8GfAUzNE+C4B3d8U2OREXlGNTJ5IQ8D3QbT8yr/1mZ98LWnkVQYcJXO0 zhNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726911514; x=1727516314; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0XRmMeXEe5yP0mGWkSfifMav5MsQOEkLLReI4uKemqQ=; b=XsxMZ6kZNBjhKgpX6JbJT2Mgo2tXcEdXH+M6VqbMslOlMOYHaHikVTxX8cFz+Sf2uL 4VSOy4oCfSG0PY6gkvmIYgo3fteIuBY/qTkWZX2dSd+tUpNIiApgbSCv93ZVqRuXIkED Zta6z2xacf/SolnlHh5YD2fZRC0FH9jnRr79qpya0zPjLwn2uKlZFliGJqH6T2eRv0HH EBb9IwUb3bkVkOJuXmbV65d9gh+PFWjmDlmLZqGmMWmi4mJwZNkqOFw2M4RfjL9IMP4C AH5sFbfrVtZpxCA7Cg0+K83Y74bP150pUwI8cOPXxfGJ0Ey2B9Tn2jFxWkMt4YnakHjk l4rQ== X-Forwarded-Encrypted: i=1; AJvYcCVprMoJVSYQaVtaDuCf+6GRGRUCoaRRKAXQiWBseRV6hPy9iU3FfqBp/w7AQnQL93X4BYLs/G4h@notmuchmail.org X-Gm-Message-State: AOJu0YwZfagrCx7hyRzmYfDXOim3W1s3K47KuWwZ+268jzfoaJzTkmaG jOvuRK3IM7tMXscpsz1zAnYYRTqLY2QbFZ1Idxed5fedYSj8gfbflb5FOosk+8jCKLmU/9z/LIq Iq0ADmcUOjE7+Nx1Hz3G8VqQpGOg= X-Google-Smtp-Source: AGHT+IHTDLUAe99Ow25I62gFrNLjNRHjAHFmE5MqcMj7fpW5xHM8pDToioyThK4MRjoYxFOdGM6QbWOb1wFqZkOk2Do= X-Received: by 2002:a17:907:f762:b0:a8d:fa3:bb24 with SMTP id a640c23a62f3a-a90d4fe8370mr457448466b.23.1726911514169; Sat, 21 Sep 2024 02:38:34 -0700 (PDT) MIME-Version: 1.0 References: <20240920175232.zryeqyl76nbydiab@localhost> <87zfo1dfa1.fsf@pengjiz.com> <20240921032340.opozeclfbyqzw2yt@localhost> In-Reply-To: <20240921032340.opozeclfbyqzw2yt@localhost> From: Michael J Gruber Date: Sat, 21 Sep 2024 11:38:18 +0200 Message-ID: Subject: Re: searching for a message by path To: frederik@ofb.net Message-ID-Hash: BDFKHR7FWUMJFVXGYAKSERCWQXGRA7RX X-Message-ID-Hash: BDFKHR7FWUMJFVXGYAKSERCWQXGRA7RX X-MailFrom: michaeljgruber@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Pengji Zhang , notmuch@notmuchmail.org X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE X-Migadu-Spam-Score: -3.11 X-Spam-Score: -3.11 X-Migadu-Queue-Id: 5D1869110 X-Migadu-Scanner: mx10.migadu.com X-TUID: GZsHaq2mYJqG Am Sa., 21. Sept. 2024 um 05:23 Uhr schrieb Frederick Eaton : > > Thank you for your response, Pengji. > > On Sat, Sep 21, 2024 at 08:25:10AM +0800, Pengji Zhang wrote: > >Hi Frederick, > > > >Frederick Eaton writes: > > > >>I am trying to figure out how to adapt a script I wrote for > >>filtering messages, to apply notmuch tags to each message. A > >>difficulty is that the messages are already in the Notmuch database, > >>because another tool has delivered them to a maildir and run > >>"notmuch new". > >> > >>Now, Notmuch can provide me with the paths of all the new > >>(unfiltered) messages, which I can give to my script. The question I > >>have is, once the filter is done, how can the script tell Notmuch > >>which message to apply the tags to? > > > > > >I am not sure if I understand you correctly. If the problem here is to > >distinguish existing messages and new messages, would the config > >option 'new.tags' work? For example, use > > > > notmuch config set new.tags new > > > >to give all new messages a 'new' tag. > > No, I already have that configuration. The first sentence described what I already know how to do, the second sentence is what I'm trying to do. It seems that we're still guess-working-out what your script is doing/trying to do. Do you mind sharing a trimmed down version? > It might be useful for the reasons I stated, namely in case the Message-ID does not exist or is not unique. This is probably at the heart of the problem. Within notmuch, a "message" is something identified by a message-id (mid), and all information in the notmuch database is tied to a mid. When you speak about a message, you probably mean the content of an individual "message file" - which is a natural, but different notion. A "path:" refers to a message file, a "mid:" to message id. When "notmuch new" encounters a new message files, it - checks if it contains a valid "Message-ID" header - used that as mid or generates a mid using a sha1 checksum of the message file - checks whether that mid (!) is in the database already - adds the path to the existing db entry, or creates a new db entry So, you may have several files (path entries) for the same mid, and which one is used for indexing purposes depends on the order of arrival (or, in the case of reindexing, probably on file system ordering). notmuch assumes that this makes no difference - same mid same "message". This assumption can break, for example for list copies, different headers on sent versus received etc. I"m elaborating on this because we have to guess about your script - what is a "new message" for your script, and which kind of information does it want to process? Typical processing would be done in a notmuch post-hook, and it would: - check for new messages (tag:new) - get their file paths form `notmuch search --output=files mid:XYZ` or such - do whatever it needs using the file if you really need to parse that yourself I guess most of us have some sort of script running on new messages as part of a hook, be it `afew` or something homegrown, and this typically clears the new tag afterwards. Michael