[aiaiai PATCH v3 07/12] email-lda: process all series directories at the end
Artem Bityutskiy
dedekind1 at gmail.com
Thu Feb 6 02:33:00 PST 2014
From: Jacob Keller <jacob.e.keller at intel.com>
Sometimes the email-lda program can misbehave and a series could end up
becoming "complete" but the LDA does not queue it when the last patch was
added. This patch modifies the LDA so that it will check all series at the end
of each mail and queue them, rather than only checking a series when some
thing is added.
The primary benefit of this is if a series does not properly get queued, the
administrator can come in and manually add the patches to the series
directory. Then the series will properly be "queued" after the next email
triggers the LDA.
This does come at a slight hit in terms of performance as we now have to check
whether series are complete for every email. However, the gain in being able
to easily fixup and get a series queued again when errors occur is much more
useful.
Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
email/aiaiai-email-lda | 74 ++++++++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 21 deletions(-)
diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda
index 3f7746e..c212a8a 100755
--- a/email/aiaiai-email-lda
+++ b/email/aiaiai-email-lda
@@ -170,6 +170,35 @@ series_is_complete()
fi
}
+queue_series()
+{
+ local dir="$1"; shift
+ local n="$1"; shift
+ local m="1"
+
+ # If the series is complete - queue it
+ if series_is_complete "$dir" "$n"; then
+ message "Patch-set at \"$dir\" is complete, queue it"
+ # Don't add the 0th patch, as it should be empty, and screws up git-am
+ for fname in $(ls --ignore=0 -A -- "$dir" | sort -n); do
+ cat -- "$dir/$fname" >> "$mbox"
+ echo >> "$mbox"
+ done
+
+ # Add the series subject if it exists
+ if [[ -f "$dir/0" ]]; then
+ program_required "sponge" "Installed with the moreutils package."
+ series_subject="$(fetch_header "Subject" < "$dir/0")"
+ # Use sponge so we don't have to manually maintain a specific file
+ formail -s formail -I "X-Series-Subject: $series_subject" < "$mbox" | sponge "$mbox"
+ m="0"
+ fi
+
+ queue_mboxfile
+ rm $verbose -rf -- "$dir" >&2
+ fi
+}
+
move_to_series()
{
local file="$1"; shift
@@ -267,27 +296,6 @@ EOF
for relative in $staging_relatives; do
move_to_series "$relative" "$dir" "$n"
done
-
- # If the series is complete - queue it
- if series_is_complete "$dir" "$n"; then
- message "Patch-set at \"$dir\" is complete, queue it"
- # Don't add the 0th patch, as it should be empty, and screws up git-am
- for fname in $(ls --ignore=0 -A -- "$dir" | sort -n); do
- cat -- "$dir/$fname" >> "$mbox"
- echo >> "$mbox"
- done
-
- # Add the series subject if it exists
- if [[ -f "$dir/0" ]]; then
- program_required "sponge" "Installed with the moreutils package."
- series_subject="$(fetch_header "Subject" < "$dir/0")"
- # Use sponge so we don't have to store to use two separate temporary files
- formail -s formail -I "X-Series-Subject: $series_subject" < "$mbox" | sponge "$mbox"
- fi
-
- queue_mboxfile
- rm $verbose -rf -- "$dir" >&2
- fi
}
# Process one e-mail stored in the $mbox temporary file
@@ -339,6 +347,29 @@ process_mbox()
fi
}
+process_all_series()
+{
+ local dir
+ local n
+ program_required "find" ""
+
+ # Get all the current series
+ while read -r dir; do
+ # Don't run on empty input!
+ [ -n "$dir" ] || continue;
+
+ # Extract the series number
+ n=${dir%-*}
+ n=${n##*_}
+
+ # Clear anything from the current mbox
+ rm -f $mbox
+
+ queue_series "$dir" "$n"
+
+ done <<< "$(find "$series" -mindepth 1 -maxdepth 1 -type d)"
+}
+
reap_old()
{
local dir="$1"; shift
@@ -464,6 +495,7 @@ done
printf "%s\n" "$prev" >> "$mbox"
process_mbox
+process_all_series
[ -z "$incomplete_min" ] || reap_old "$lda_tmp" "$incomplete_min"
[ -z "$archive_min" ] || reap_old "$mail" "$archive_min"
--
Best Regards,
Artem Bityutskiy
More information about the aiaiai
mailing list