From b3209cd5c468e2364a3a04ee298cfb0e1a6c30e7 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Mon, 23 Jan 2023 12:20:09 -0800
Subject: [PATCH] We need store the file full path in the section name

We need to support the same filename in different directories.

The 'path' key is just an artifact and not normally used when read,
so that was a distraction that apparently confused me previously
and I broke this functionality in commit c44ed79a3b2c5e5.

This should fix the issues reported by xbit (XBITBBS) on DOVE-Net.

Also, don't open the file.ini for write-access (unnecessary).
---
 exec/text_sec.js | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/exec/text_sec.js b/exec/text_sec.js
index 53382abd8e..5ff8bffa87 100644
--- a/exec/text_sec.js
+++ b/exec/text_sec.js
@@ -10,7 +10,7 @@ require("cga_defs.js", 'LIGHTGRAY');
 require("sbbsdefs.js", 'P_CPM_EOF');
 
 var file_cnf = new File(system.ctrl_dir + "file.ini");
-if(!file_cnf.open(file_cnf.exists ? 'r+':'w+')) {
+if(!file_cnf.open('r')) {
 	alert("Error opening " + file_cnf.name);
 	exit(0);
 }
@@ -114,7 +114,7 @@ while(bbs.online) {
 						break;
 					i--;
 				}
-				var path;
+				var fname;
 				var files = directory(backslash(txtsec_data(usrsec[cursec])) + "*");
 				for(var f = 0; f < files.length; f++) {
 					var match = false;
@@ -123,24 +123,25 @@ while(bbs.online) {
 							match = true;
 					}
 					if(!match) {
-						path = file_getname(files[f]);
+						fname = file_getname(files[f]);
 						break;
 					}
 				}
 				console.print(format(bbs.text(AddTextFilePath)
 					,system.data_dir, usrsec[cursec].code.toLowerCase()));
-				var path = console.getstr(path, 128, K_EDIT|K_LINE|K_TRIM);
-				if(!path || console.aborted)
+				fname = console.getstr(fname, 128, K_EDIT|K_LINE|K_TRIM);
+				if(!fname || console.aborted)
 					break;
+				var path = fname;
 				if(!file_exists(path))
-					path = backslash(txtsec_data(usrsec[cursec])) + path;
+					path = backslash(txtsec_data(usrsec[cursec])) + fname;
 				console.printfile(path);
 				console.crlf();
 				console.print(bbs.text(AddTextFileDesc));
 				var desc = console.getstr(file_getname(path), 70, K_EDIT|K_LINE|K_TRIM|K_AUTODEL);
 				if(!desc || console.aborted)
 					break;
-				list.splice(i, 0, { name: file_getname(path), desc: desc, path: path });
+				list.splice(i, 0, { name: path, desc: desc });
 				write_list(usrsec[cursec], list);
 				break;
 			}
-- 
GitLab