Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 288571) +++ apps/app_voicemail.c (working copy) @@ -1539,7 +1539,7 @@ return messagecount(context, tmp, folder) ? 1 : 0; } -static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir) +static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir, int from_fs) { struct vm_state *sendvms = NULL, *destvms = NULL; char messagestring[10]; /*I guess this could be a problem if someone has more than 999999999 messages...*/ @@ -3905,7 +3905,7 @@ #endif #ifndef IMAP_STORAGE /* copy message only used by file storage */ -static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir) +static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir, int fromfs) { char fromdir[PATH_MAX], todir[PATH_MAX], frompath[PATH_MAX], topath[PATH_MAX]; const char *frombox = mbox(imbox); @@ -3934,7 +3934,10 @@ recipmsgnum++; } while (recipmsgnum < recip->maxmsg); if (recipmsgnum < recip->maxmsg - (imbox ? 0 : inprocess_count(vmu->mailbox, vmu->context, 0))) { - if (EXISTS(fromdir, msgnum, frompath, chan->language)) { + /* If we are prepending a message for ODBC, then the message already + * exists in the database, but we want to force copying from the + * filesystem (since only the FS contains the prepend). */ + if (!fromfs && EXISTS(fromdir, msgnum, frompath, chan->language)) { COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath); } else { /* For ODBC storage, if the file we want to copy isn't yet in the database, then the SQL @@ -4444,7 +4447,7 @@ context++; } if ((recip = find_user(&recipu, context, exten))) { - copy_message(chan, vmu, 0, msgnum, duration, recip, fmt, dir); + copy_message(chan, vmu, 0, msgnum, duration, recip, fmt, dir, 1); free_user(recip); } } @@ -5485,7 +5488,7 @@ /* NULL category for IMAP storage */ sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, dstvms->curbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL); #else - copy_msg_result = copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir); + copy_msg_result = copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir, 1); #endif saved_messages++; inprocess_count(vmtmp->mailbox, vmtmp->context, -1);