[PATCH 09/16] email-lda: centralise naming decision

Artem Bityutskiy dedekind1 at gmail.com
Thu Feb 6 08:30:55 PST 2014


From: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>

The 'sec_name' function basically defines the name of the mbox file or a
directory for use. Currently we use the date as the prefix. Later we may change
this.

Anyway, make 'sec_name' always use the current date, isntead of getting it from
the caller. This should make things a bit easier to understand.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
---
 email/aiaiai-email-lda | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda
index 84a9bbb..940db22 100755
--- a/email/aiaiai-email-lda
+++ b/email/aiaiai-email-lda
@@ -123,18 +123,20 @@ reject_and_reply()
 seq_name()
 {
 	local where="$1"; shift
-	local name="$1"; shift
+	local suffix="$1"; shift
+	local path="$where/${date}_${suffix}-"
 	local i=0
 
-	while [ -e "${where}/${name}-${i}" ]; do
+	while [ -e "${path}${i}" ]; do
 		i="$(($i+1))"
 	done
-	printf "%s" "$where/$name-$i"
+
+	printf "%s" "${path}${i}"
 }
 
 queue_mboxfile()
 {
-	local fname="$(seq_name "$queue" "${date}_${n}")"
+	local fname="$(seq_name "$queue" "$n")"
 	cp $verbose -- "$mbox" "$queue_saved/${fname##*/}" >&2
 	mv $verbose -- "$mbox" "$fname" >&2
 }
@@ -293,7 +295,7 @@ EOF
 
 	if [ -z "$staging_relatives" ] && [ -z "$series_relatives" ]; then
 		# Save the file in the staging area
-		fname="$(seq_name "$staging" "${date}_${m}-of-${n}")"
+		fname="$(seq_name "$staging" "$m-of-$n")"
 		verbose "No relatives found, temporarily save in staging"
 		mv $verbose -- "$mbox" "$fname" >&2
 		return
@@ -303,7 +305,7 @@ EOF
 
 	if [ -z "$series_relatives" ]; then
 		# The series directory does not exist yet - create it
-		dir="$(seq_name "$series" "${date}_${n}")"
+		dir="$(seq_name "$series" "$n")"
 		verbose "Creating the series directory \"$dir\""
 		mkdir $verbose -- "$dir" >&2
 	else
-- 
1.8.5.2




More information about the aiaiai mailing list