From 24bf49ea8843706ebbc7dfc9794d0207b3706338 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Sun, 2 May 2021 01:42:46 -0700
Subject: [PATCH] Add a 'readd_always' option to the update() method

This will cause archive file contents to be re-captured/added
---
 src/sbbs3/js_filebase.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/js_filebase.c b/src/sbbs3/js_filebase.c
index bf0a2a35c5..b7ecd5e278 100644
--- a/src/sbbs3/js_filebase.c
+++ b/src/sbbs3/js_filebase.c
@@ -1258,6 +1258,7 @@ js_update_file(JSContext *cx, uintN argc, jsval *arglist)
 	char*		filename = NULL;
 	JSObject*	fileobj = NULL;
 	bool		use_diz_always = false;
+	bool		readd_always = false;
 	jsrefcount	rc;
 
 	ZERO_VAR(file);
@@ -1291,6 +1292,10 @@ js_update_file(JSContext *cx, uintN argc, jsval *arglist)
 		use_diz_always = JSVAL_TO_BOOLEAN(argv[argn]);
 		argn++;
 	}
+	if(argn < argc && JSVAL_IS_BOOLEAN(argv[argn])) {
+		readd_always = JSVAL_TO_BOOLEAN(argv[argn]);
+		argn++;
+	}
 
 	JSBool result = JS_TRUE;
 	char* extdesc = NULL;
@@ -1317,7 +1322,7 @@ js_update_file(JSContext *cx, uintN argc, jsval *arglist)
 			} else {
 				if(file.extdesc != NULL)
 					truncsp(file.extdesc);
-				if(strcmp(extdesc ? extdesc : "", file.extdesc ? file.extdesc : "") == 0)
+				if(!readd_always && strcmp(extdesc ? extdesc : "", file.extdesc ? file.extdesc : "") == 0)
 					p->smb_result = smb_putfile(&p->smb, &file);
 				else {
 					if((p->smb_result = smb_removefile(&p->smb, &file)) == SMB_SUCCESS) {
@@ -1721,7 +1726,7 @@ static jsSyncMethodSpec js_filebase_functions[] = {
 		,31900
 	},
 	{"update",			js_update_file,		3, JSTYPE_BOOLEAN
-		,JSDOCSTR("filename, file-meta-object [,use_diz_always=false]")
+		,JSDOCSTR("filename, file-meta-object [,use_diz_always=false] [,readd_always=false]")
 		,JSDOCSTR("update an existing file in the file base"
 				", may throw exception on errors (e.g. file rename failure)")
 		,31900
-- 
GitLab