* [PATCH] lei export-kw: workaround race in updating Maildir locations
@ 2021-08-05 2:33 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-08-05 2:33 UTC (permalink / raw)
To: meta
Inotify updates may simultaneously remove or update the location
of a message, so ensure we at least have knowledge of the new
location if the old one cannot be updated.
---
lib/PublicInbox/LeiMailSync.pm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index 82740d59..6dfa03be 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -158,7 +158,13 @@ sub mv_src {
my $sth = $self->{dbh}->prepare_cached(<<'');
UPDATE blob2name SET name = ? WHERE fid = ? AND oidbin = ? AND name = ?
- $sth->execute($newbn, $fid, $oidbin, $$id);
+ my $nr = $sth->execute($newbn, $fid, $oidbin, $$id);
+ if ($nr == 0) { # may race with a clear_src, ensure new value exists
+ $sth = $self->{dbh}->prepare_cached(<<'');
+INSERT OR IGNORE INTO blob2name (oidbin, fid, name) VALUES (?, ?, ?)
+
+ $sth->execute($oidbin, $fid, $newbn);
+ }
}
# read-only, iterates every oidbin + UID or name for a given folder
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-05 2:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-05 2:33 [PATCH] lei export-kw: workaround race in updating Maildir locations Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.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).