diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-02-06 15:54:21 +0200 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-02-07 10:56:26 +0200 |
commit | 58fb5507bece94d44cd265e399f428ae44715d44 (patch) | |
tree | 7e99110966330aaaabbb4b3127e1518f70009919 | |
parent | 8a3fd5484d78b1f0ceec9dfa6f64ceccab728a9b (diff) | |
download | aiaiai-58fb5507bece94d44cd265e399f428ae44715d44.tar.gz |
email-lda: rename seq_name
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>
-rwxr-xr-x | email/aiaiai-email-lda | 15 |
1 files 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 |