[sword-svn] r3868 - trunk/src/mgr

scribe at crosswire.org scribe at crosswire.org
Sun Oct 10 13:18:41 EDT 2021


Author: scribe
Date: 2021-10-10 13:18:41 -0400 (Sun, 10 Oct 2021)
New Revision: 3868

Modified:
   trunk/src/mgr/installmgr.cpp
Log:
Added two new generated conf values when installing a module to record the repo source: InstallSourceID, InstallSourceCaption


Modified: trunk/src/mgr/installmgr.cpp
===================================================================
--- trunk/src/mgr/installmgr.cpp	2021-10-10 17:15:21 UTC (rev 3867)
+++ trunk/src/mgr/installmgr.cpp	2021-10-10 17:18:41 UTC (rev 3868)
@@ -402,6 +402,8 @@
 	bool aborted = false;
 	bool cipher = false;
 	SWBuf modFile;
+	SWBuf sourceUID = "local";
+	SWBuf sourceCaption = "local";
 
 SWLOGD("***** InstallMgr::installModule\n");
 	if (fromLocation) {
@@ -409,8 +411,11 @@
 	}
 SWLOGD("***** modName: %s \n", modName);
 
-	if (is)
+	if (is) {
 		sourceDir = (SWBuf)privatePath + "/" + is->uid;
+		sourceUID = is->uid;
+		sourceCaption = is->caption;
+	}
 	else	sourceDir = fromLocation;
 
 	removeTrailingSlash(sourceDir);
@@ -511,6 +516,7 @@
 				}
 			}
 		}
+		// find and copy the .conf file
 		if (!aborted) {
 			SWBuf confDir = sourceDir + "mods.d/";
 			std::vector<DirEntry> dirList = FileMgr::getDirList(confDir);
@@ -519,6 +525,8 @@
 					modFile = confDir;
 					modFile += dirList[i].name;
 					SWConfig *config = new SWConfig(modFile);
+
+					// we found a conf file with our module
 					if (config->getSections().find(modName) != config->getSections().end()) {
 						SWBuf targetFile = destMgr->configPath; //"./mods.d/";
 						removeTrailingSlash(targetFile);
@@ -536,7 +544,14 @@
 								retVal = FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
 							}
 						}
+						// let's add our install source information
+						SWConfig *newConfig = new SWConfig(targetFile.c_str());
+						newConfig->setValue(modName, "InstallSourceID", sourceUID);
+						newConfig->setValue(modName, "InstallSourceCaption", sourceCaption);
+						newConfig->save();
+						delete newConfig;
 					}
+
 					delete config;
 				}
 			}



More information about the sword-cvs mailing list