From 69e23e724e4e9dd2cd905b7da7d9d74f0f4a70a6 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Sat, 30 Nov 2024 20:56:46 -0800
Subject: [PATCH] Move the backup of dsts.ini before opening the file

Can't backup (make copies of) an open file.
---
 src/sbbs3/logon.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/logon.cpp b/src/sbbs3/logon.cpp
index 2f64c0f635..ecf2681b5f 100644
--- a/src/sbbs3/logon.cpp
+++ b/src/sbbs3/logon.cpp
@@ -646,6 +646,8 @@ uint sbbs_t::logonstats()
 					node.misc|=NODE_EVENT;
 					putnodedat(i,&node); 
 				}
+				dstats_fname(&cfg, i, path, sizeof path);
+				backup(path, 90, /* rename: */false);
 				if((dsts = fopen_dstats(&cfg, i, /* for_write: */TRUE)) == NULL) /* doesn't have stats yet */
 					continue;
 
@@ -655,14 +657,12 @@ uint sbbs_t::logonstats()
 					continue;
 				}
 
-				dstats_fname(&cfg, i, path, sizeof path);
 				if(!fread_dstats(dsts, &stats)) {
 					errormsg(WHERE, ERR_READ, path, i);
 				} else {
 					stats.date = time(NULL);
 					fwrite_cstats(csts, &stats);
 					rolloverstats(&stats);
-					backup(path, 90, /* rename: */false);
 					if(!fwrite_dstats(dsts, &stats, __FUNCTION__))
 						errormsg(WHERE, ERR_WRITE, path, i);
 				}
-- 
GitLab