[PATCH v2 10/16] email-lda: rename seq_name

Artem Bityutskiy dedekind1 at gmail.com
Fri Feb 7 00:50:39 PST 2014


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

This name is not self-documenting, make it "generate_file_name()" instead.
Also, add a better commentary to this function.

This is for the sake of code readability.

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

diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda
index 940db22..5c02a23 100755
--- a/email/aiaiai-email-lda
+++ b/email/aiaiai-email-lda
@@ -118,9 +118,12 @@ reject_and_reply()
 	fi
 }
 
-# Generate unique name - a bit more readable than mktemp creates. We assume
-# that we exclusively own the directory where we create the temporary file.
-seq_name()
+# Generate unique name for a file or directory in the "$1" subdirectory.
+# Currently we use the same format: <date>_<suffix>-<counter>, where <date> is
+# the current date (taken from the global $date variable), <suffix> is the
+# a suffix supplied by the caller via "$2", and <counter> is usually 0, but if
+# there is alreay a file with such name, it gets increased to 1, and so on.
+generate_file_name()
 {
 	local where="$1"; shift
 	local suffix="$1"; shift
@@ -136,7 +139,7 @@ seq_name()
 
 queue_mboxfile()
 {
-	local fname="$(seq_name "$queue" "$n")"
+	local fname="$(generate_file_name "$queue" "$n")"
 	cp $verbose -- "$mbox" "$queue_saved/${fname##*/}" >&2
 	mv $verbose -- "$mbox" "$fname" >&2
 }
@@ -295,7 +298,7 @@ EOF
 
 	if [ -z "$staging_relatives" ] && [ -z "$series_relatives" ]; then
 		# Save the file in the staging area
-		fname="$(seq_name "$staging" "$m-of-$n")"
+		fname="$(generate_file_name "$staging" "$m-of-$n")"
 		verbose "No relatives found, temporarily save in staging"
 		mv $verbose -- "$mbox" "$fname" >&2
 		return
@@ -305,7 +308,7 @@ EOF
 
 	if [ -z "$series_relatives" ]; then
 		# The series directory does not exist yet - create it
-		dir="$(seq_name "$series" "$n")"
+		dir="$(generate_file_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