* [PATCH] Handle rename of message file
@ 2009-11-17 20:51 Mikhail Gusarov
2009-11-19 1:08 ` Carl Worth
0 siblings, 1 reply; 6+ messages in thread
From: Mikhail Gusarov @ 2009-11-17 20:51 UTC (permalink / raw)
To: notmuch
If message file has been renamed, just update filename in the DB.
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
---
lib/database.cc | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lib/database.cc b/lib/database.cc
index 3c8d626..c4eb8b6 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -925,20 +925,23 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
_notmuch_message_set_filename (message, filename);
_notmuch_message_add_term (message, "type", "mail");
+
+ ret = _notmuch_database_link_message (notmuch, message, message_file);
+ if (ret)
+ goto DONE;
+
+ date = notmuch_message_file_get_header (message_file, "date");
+ _notmuch_message_set_date (message, date);
+
+ _notmuch_message_index_file (message, filename);
+ } else if (strcmp(notmuch_message_get_filename(message), filename)) {
+ /* Message file has been moved/renamed */
+ _notmuch_message_set_filename (message, filename);
} else {
ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
goto DONE;
}
- ret = _notmuch_database_link_message (notmuch, message, message_file);
- if (ret)
- goto DONE;
-
- date = notmuch_message_file_get_header (message_file, "date");
- _notmuch_message_set_date (message, date);
-
- _notmuch_message_index_file (message, filename);
-
_notmuch_message_sync (message);
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred: %s.\n",
--
1.6.3.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Handle rename of message file
2009-11-17 20:51 [PATCH] Handle rename of message file Mikhail Gusarov
@ 2009-11-19 1:08 ` Carl Worth
2009-11-19 1:14 ` Mikhail Gusarov
2009-11-19 2:06 ` Keith Packard
0 siblings, 2 replies; 6+ messages in thread
From: Carl Worth @ 2009-11-19 1:08 UTC (permalink / raw)
To: Mikhail Gusarov, notmuch
On Wed, 18 Nov 2009 02:51:18 +0600, Mikhail Gusarov <dottedmag@dottedmag.net> wrote:
> If message file has been renamed, just update filename in the DB.
>
> Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
I believe you said in IRC that this patch is not ready yet.
I'd love to hear more from you on any experiments/ideas you have in this
area. It would be a really nice feature to have, (particularly for
people who are experimenting with notmuch while still using some other
primary email program that keeps fiddling with the filenames).
-Carl
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Handle rename of message file
2009-11-19 1:08 ` Carl Worth
@ 2009-11-19 1:14 ` Mikhail Gusarov
2009-11-19 2:06 ` Keith Packard
1 sibling, 0 replies; 6+ messages in thread
From: Mikhail Gusarov @ 2009-11-19 1:14 UTC (permalink / raw)
To: Carl Worth; +Cc: notmuch
[-- Attachment #1: Type: text/plain, Size: 863 bytes --]
Twas brillig at 02:08:15 19.11.2009 UTC+01 when cworth@cworth.org did gyre and gimble:
CW> I believe you said in IRC that this patch is not ready yet.
Yes.
CW> I'd love to hear more from you on any experiments/ideas you have in
CW> this area. It would be a really nice feature to have, (particularly
CW> for people who are experimenting with notmuch while still using
CW> some other primary email program that keeps fiddling with the
CW> filenames).
Did not have time to work on it further yet.
The only dumb idea I have in mind is hardlinking all mail to separate
directory in order to make a "pristine copy" which does not change as
time goes. This directory could be cleaned up: if some file has only 1
link, then it was deleted from main mail spool and should be deleted
From copy too.
--
http://fossarchy.blogspot.com/
[-- Attachment #2: Type: application/pgp-signature, Size: 834 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Handle rename of message file
2009-11-19 1:08 ` Carl Worth
2009-11-19 1:14 ` Mikhail Gusarov
@ 2009-11-19 2:06 ` Keith Packard
2009-11-19 2:11 ` Mikhail Gusarov
1 sibling, 1 reply; 6+ messages in thread
From: Keith Packard @ 2009-11-19 2:06 UTC (permalink / raw)
To: Carl Worth, Mikhail Gusarov, notmuch
[-- Attachment #1: Type: text/plain, Size: 820 bytes --]
On Thu, 19 Nov 2009 02:08:15 +0100, Carl Worth <cworth@cworth.org> wrote:
> I'd love to hear more from you on any experiments/ideas you have in this
> area. It would be a really nice feature to have, (particularly for
> people who are experimenting with notmuch while still using some other
> primary email program that keeps fiddling with the filenames).
Checking for new files is easy; notmuch already does that, and so
handling renames doesn't seem all that difficult. The hard part to me is
detecting deleted messages; about the only thing I can imagine being at
all efficient is to use inotify in a daemon. Starting that daemon up
would entail scanning the database for all messages in a particular
directory and then looking for those files to see if they were still
around. Ick.
--
keith.packard@intel.com
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Handle rename of message file
2009-11-19 2:06 ` Keith Packard
@ 2009-11-19 2:11 ` Mikhail Gusarov
2009-11-19 3:12 ` Keith Packard
0 siblings, 1 reply; 6+ messages in thread
From: Mikhail Gusarov @ 2009-11-19 2:11 UTC (permalink / raw)
To: notmuch
[-- Attachment #1: Type: text/plain, Size: 357 bytes --]
Twas brillig at 18:06:09 18.11.2009 UTC-08 when keithp@keithp.com did gyre and gimble:
KP> Checking for new files is easy; notmuch already does that, and so
KP> handling renames doesn't seem all that difficult.
Except rename does not change mtime of file, and so it won't be picked
up by 'notmuch new'.
--
http://fossarchy.blogspot.com/
[-- Attachment #2: Type: application/pgp-signature, Size: 834 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Handle rename of message file
2009-11-19 2:11 ` Mikhail Gusarov
@ 2009-11-19 3:12 ` Keith Packard
0 siblings, 0 replies; 6+ messages in thread
From: Keith Packard @ 2009-11-19 3:12 UTC (permalink / raw)
To: Mikhail Gusarov, notmuch
[-- Attachment #1: Type: text/plain, Size: 953 bytes --]
On Thu, 19 Nov 2009 08:11:12 +0600, Mikhail Gusarov <dottedmag@dottedmag.net> wrote:
>
> Twas brillig at 18:06:09 18.11.2009 UTC-08 when keithp@keithp.com did gyre and gimble:
>
> KP> Checking for new files is easy; notmuch already does that, and so
> KP> handling renames doesn't seem all that difficult.
>
> Except rename does not change mtime of file, and so it won't be picked
> up by 'notmuch new'.
Yeah, good point -- notmuch new doesn't make sure each file it finds is
already in the database. Again, some kind of inotify-based daemon would
make that efficient, while starting up that daemon could take some time
while the database was searched for new or missing files.
Alternatively, we could record the contents of the directory after
scanning it and then use that to track file changes. It seems like the
current database just doesn't have enough information to make this
tractable.
--
keith.packard@intel.com
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-19 3:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 20:51 [PATCH] Handle rename of message file Mikhail Gusarov
2009-11-19 1:08 ` Carl Worth
2009-11-19 1:14 ` Mikhail Gusarov
2009-11-19 2:06 ` Keith Packard
2009-11-19 2:11 ` Mikhail Gusarov
2009-11-19 3:12 ` Keith Packard
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).