Second attempt unzip mail archives patch

This commit is contained in:
Michiel Broek 2002-02-15 19:29:33 +00:00
parent 6e31daa907
commit 509b9bbc2b
2 changed files with 39 additions and 30 deletions

View File

@ -4610,6 +4610,9 @@ v0.33.20 10-Feb-2002
from a uplink which has a echomail taglist in one of the
mailgroups defined. The area is created with the defaults
from the mailgroup.
If mbfido fails to unzip a incoming mailarchive, a second
attempt is done after a sync() and one second delay. This
seems to be a kernel flush problem.
mball:
Will not crash anymore when it needs more then 10 minutes to

View File

@ -139,43 +139,49 @@ int checkspace(char *dir, char *fn, int factor)
*/
int unpack(char *fn)
{
char newname[16];
char *cmd = NULL, *unarc;
int rc = 0, ld;
char newname[16];
char *cmd = NULL, *unarc;
int rc = 0, ld;
if (!do_quiet) {
colour(11, 0);
printf("Unpacking file %s\n", fn);
}
if (!do_quiet) {
colour(11, 0);
printf("Unpacking file %s\n", fn);
}
if ((unarc = unpacker(fn)) == NULL)
return 1;
if ((unarc = unpacker(fn)) == NULL)
return 1;
if (!getarchiver(unarc))
return 1;
if (!getarchiver(unarc))
return 1;
cmd = xstrcpy(archiver.munarc);
cmd = xstrcpy(archiver.munarc);
if ((cmd == NULL) || (cmd == ""))
return -1;
if ((ld = f_lock(fn)) == -1) {
free(cmd);
return 1;
}
rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null");
if (rc == 0)
unlink(fn);
else {
strncpy(newname,fn,sizeof(newname)-1);
strcpy(newname+8,".bad");
rename(fn,newname);
}
if ((cmd == NULL) || (cmd == ""))
return -1;
if ((ld = f_lock(fn)) == -1) {
free(cmd);
funlock(ld);
return rc;
return 1;
}
if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
unlink(fn);
} else {
sync();
sleep(1);
Syslog('!', "Warning: unpack %s failed, trying again after sync()");
if ((rc = execute(cmd,fn,(char *)NULL,(char*)"/dev/null",(char*)"/dev/null",(char*)"/dev/null")) == 0) {
unlink(fn);
} else {
strncpy(newname,fn,sizeof(newname)-1);
strcpy(newname+8,".bad");
rename(fn,newname);
}
}
free(cmd);
funlock(ld);
return rc;
}