char tmp[80] = "/tmp/astmail-XXXXXX";
long len;
void *buf;
+ int tempcopy = 0;
STRING str;
/* Attach only the first format */
else
ast_copy_string (fn, dir, sizeof(fn));
- if (ast_strlen_zero(vmu->email))
+ if (ast_strlen_zero(vmu->email)) {
+ /*we need the vmu->email to be set when we call make_email_file, but if we keep it set,
+ * a duplicate e-mail will be created. So at the end of this function, we will revert back to an empty
+ * string if tempcopy is 1
+ */
ast_copy_string(vmu->email, vmu->imapuser, sizeof(vmu->email));
+ tempcopy = 1;
+ }
if (!strcmp(fmt, "wav49"))
fmt = "WAV";
command hangs */
if (!(p = vm_mkftemp(tmp))) {
ast_log(LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
+ if(tempcopy)
+ *(vmu->email) = '\0';
return -1;
}
rewind(p);
if (!(buf = ast_malloc(len+1))) {
ast_log(LOG_ERROR, "Can't allocate %ld bytes to read message\n", len+1);
+ if(tempcopy)
+ *(vmu->email) = '\0';
return -1;
}
fread(buf, len, 1, p);
unlink(tmp);
ast_free(buf);
ast_debug(3, "%s stored\n", fn);
+
+ if(tempcopy)
+ *(vmu->email) = '\0';
+
return 0;
}