]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
listcontrol: reduce I/O in moderation
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 14 Apr 2023 11:18:52 +0000 (13:18 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 14 Apr 2023 11:18:52 +0000 (13:18 +0200)
src/listcontrol.c

index e5c2922fce160de05fb255a14a1ec555e99c9969..afbf51765ccd8b5736b4f8be5796642e63cc490d 100644 (file)
@@ -437,21 +437,20 @@ int listcontrol(strlist *fromemails, struct ml *ml,
                }
 
                xasprintf(&moderatefilename, "moderation/%s", param);
-               if (faccessat(ml->fd, moderatefilename, F_OK, 0) < 0) {
-                       free(moderatefilename);
-                       /* no mail to moderate */
-                       errno = 0;
-                       log_error(LOG_ARGS, "A release request was"
-                               " sent with a mismatching cookie."
-                               " Ignoring mail");
-                       return -1;
-               }
-
                xasprintf(&sendfilename, "%s.sending", moderatefilename);
                /* Rename it to avoid mail being sent twice */
-               if(renameat(ml->fd, moderatefilename, ml->fd, sendfilename) < 0) {
-                       log_error(LOG_ARGS, "Could not rename to .sending");
-                       exit(EXIT_FAILURE);
+               if(renameat(ml->fd, moderatefilename, ml->fd, sendfilename) != 0) {
+                       if (errno == ENOENT) {
+                               errno = 0;
+                               log_error(LOG_ARGS, "A release request was"
+                                       " sent with a mismatching cookie."
+                                       " Ignoring mail");
+                       } else {
+                               log_error(LOG_ARGS, "Could not rename to .sending");
+                       }
+                       free(sendfilename);
+                       free(moderatefilename);
+                       return (-1);
                }
 
                xasprintf(&omitfilename, "%s.omit", moderatefilename);