Don't clobber old qwk rep files

This commit is contained in:
Andrew Pamment 2018-10-31 12:54:00 +10:00
parent 64ae6556f1
commit 99feabb6e5
2 changed files with 20 additions and 7 deletions

View File

@ -17,14 +17,20 @@ def dostuff(config_file):
repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP" repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP"
exists = os.path.isfile(repfile) i = 1
if exists: while True:
file = open(repfile, "rb") exists = os.path.isfile(repfile)
ftp.storbinary("STOR " + config.get("Main", "Host") + ".REP", file) if exists:
file.close() file = open(repfile, "rb")
os.remove(repfile) ftp.storbinary("STOR " + config.get("Main", "Host") + ".REP", file)
print("SENT: " + config.get("Main", "Host") + ".REP") file.close()
os.remove(repfile)
print("SENT: " + config.get("Main", "Host") + ".REP")
repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP." + i
i = i + 1
else:
break
qwkfile = config.get("Main", "Inbound") + "/" + config.get("Main", "Host") + ".QWK" qwkfile = config.get("Main", "Inbound") + "/" + config.get("Main", "Host") + ".QWK"
with open(qwkfile, 'wb') as file: with open(qwkfile, 'wb') as file:

View File

@ -384,6 +384,8 @@ int main(int argc, char **argv) {
char buffer[PATH_MAX]; char buffer[PATH_MAX];
char archive[PATH_MAX]; char archive[PATH_MAX];
int ret; int ret;
struct stat st;
if (argc < 2) { if (argc < 2) {
fprintf(stderr, "Usage:\n ./qwkscan config.ini\n"); fprintf(stderr, "Usage:\n ./qwkscan config.ini\n");
return -1; return -1;
@ -412,6 +414,11 @@ int main(int argc, char **argv) {
if (qwkidx > 0) { if (qwkidx > 0) {
snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid); snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid);
i = 1;
while (stat(archive, &st) == 0) {
snprintf(archive, PATH_MAX, "%s/%s.REP.%d", outbound_path, hostid, i);
i++;
}
char *b = buffer; char *b = buffer;
size_t blen = sizeof buffer; size_t blen = sizeof buffer;