Skip to content
Snippets Groups Projects
Commit 7ae0772e authored by Rob Swindell's avatar Rob Swindell :speech_balloon: Committed by Deucе
Browse files

Add another flength() check before renaming bad QWK packets

To hopefully address:
!ERROR 2 (No such file or directory) renaming s:\sbbs\data\file/somenum.rep
 (-1 bytes) to s:\sbbs\data\file/somenum.rep.6777ed7c.bad

Clearly flength() is returning -1 (file doesn't exist) at this point, so
perhaps the call to fremove() just above updated a cached directory?
parent e11e96c7
No related branches found
No related tags found
No related merge requests found
......@@ -2975,7 +2975,7 @@ void event_thread(void* arg)
}
sbbs->lprintf(LOG_DEBUG, "Opened %s", lockfile.name);
if(!fexist(fname)) {
sbbs->lprintf(LOG_NOTICE, "%s already gone", fname);
sbbs->lprintf(LOG_DEBUG, "%s already gone", fname);
if(!fmutex_close(&lockfile))
sbbs->errormsg(WHERE, ERR_CLOSE, lockfile.name);
continue;
......@@ -2995,14 +2995,16 @@ void event_thread(void* arg)
char badpkt[MAX_PATH+1];
SAFEPRINTF2(badpkt, "%s.%" PRIx64 ".bad", fname, (uint64_t)time(NULL));
sbbs->fremove(WHERE, badpkt);
if(rename(fname, badpkt) == 0)
sbbs->lprintf(LOG_NOTICE, "%s renamed to %s", fname, badpkt);
else
sbbs->lprintf(LOG_ERR, "!ERROR %d (%s) renaming %s (%ld bytes) to %s"
,errno, strerror(errno), fname, (long)flength(fname), badpkt);
SAFEPRINTF(badpkt, "%u.rep.*.bad", sbbs->useron.number);
SAFEPRINTF(str,"%sfile/", sbbs->cfg.data_dir);
sbbs->delfiles(str, badpkt, /* keep: */10);
if(flength(fname) > 0) {
if(rename(fname, badpkt) == 0)
sbbs->lprintf(LOG_NOTICE, "%s renamed to %s", fname, badpkt);
else
sbbs->lprintf(LOG_ERR, "!ERROR %d (%s) renaming %s (%ld bytes) to %s"
,errno, strerror(errno), fname, (long)flength(fname), badpkt);
SAFEPRINTF(badpkt, "%u.rep.*.bad", sbbs->useron.number);
SAFEPRINTF(str,"%sfile/", sbbs->cfg.data_dir);
sbbs->delfiles(str, badpkt, /* keep: */10);
}
}
if(!fmutex_close(&lockfile))
sbbs->errormsg(WHERE, ERR_CLOSE, lockfile.name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment