summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-02-06 15:48:52 +0200
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-02-07 10:56:26 +0200
commit8a3fd5484d78b1f0ceec9dfa6f64ceccab728a9b (patch)
tree73dcc8fd0cd8ca173199f5d5ce7dd9f0e9853146
parent011598a8339c6ba5f9c667e201f8a10db6b005ef (diff)
downloadaiaiai-8a3fd5484d78b1f0ceec9dfa6f64ceccab728a9b.tar.gz
email-lda: centralise naming decision
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@linux.intel.com>
-rwxr-xr-xemail/aiaiai-email-lda14
1 files 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