]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
email-lda: rename seq_name
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 6 Feb 2014 13:54:21 +0000 (15:54 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 7 Feb 2014 08:56:26 +0000 (10:56 +0200)
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@linux.intel.com>
email/aiaiai-email-lda

index 940db222b327ff7d28fc0b8225ab3cf7ce7b21ad..5c02a2380bfee8a930e2987f2fa7d615ee771954 100755 (executable)
@@ -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