Commit 0dee38a2 authored by rswindell's avatar rswindell
Browse files

Revamp the 0-byte inbound bundle handling:

- Don't ever try to unpack a 0-byte file.
- Don't log anything or try delete if the file is < 24 hours old.
- Try to delete the file if it's >= 24 hours old (and log a msg, INFO-level).
parent 47f3b37e
......@@ -2743,15 +2743,19 @@ bool unpack_bundle(const char* inbound)
if(gi<g.gl_pathc) {
SAFECOPY(fname,g.gl_pathv[gi]);
gi++;
lprintf(LOG_INFO,"Unpacking bundle: %s (%1.1fKB)", fname, flength(fname)/1024.0);
if(unpack(fname, inbound)) { /* failure */
lprintf(LOG_ERR, "!Unpack failure: %s", fname);
if(fdate(fname)+(48L*60L*60L)<time(NULL)) {
/* If bundle file older than 48 hours, give up */
if(flength(fname) < 1) {
off_t length = flength(fname);
if(length < 1) {
if(fdate(fname) < time(NULL) + (24*60*60))
lprintf(LOG_DEBUG, "Ignoring %ld-byte file (less than 24-hours old): ", (long)length, fname);
else {
lprintf(LOG_INFO, "Deleting %ld-byte file (more than 24-hours old): ", (long)length, fname);
delfile(fname, __LINE__); /* Delete it if it's a 0-byte file */
}
continue;
}
lprintf(LOG_INFO,"Unpacking bundle: %s (%1.1fKB)", fname, length/1024.0);
if(unpack(fname, inbound) != 0) { /* failure */
lprintf(LOG_ERR, "!Unpack failure: %s", fname);
/* rename to "*.?_?" or (if it exists) "*.?-?" */
SAFECOPY(str,fname);
str[strlen(str)-2]='_';
......@@ -2762,7 +2766,6 @@ bool unpack_bundle(const char* inbound)
if(rename(fname,str))
lprintf(LOG_ERR,"ERROR line %d renaming %s to %s"
,__LINE__,fname,str);
}
continue;
}
delfile(fname, __LINE__); /* successful, so delete bundle */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment