Index: main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java	(revision 22911)
+++ main/trunk/gli/src/org/greenstone/gatherer/greenstone/LocalLibraryServer.java	(revision 23015)
@@ -696,51 +696,34 @@
 		// GS2. We're in the constructor, so we'll be running the LLS the first time
 		// Set the correct collectdir (from last time) before the server is started up
-		String collectDir = Configuration.getString("general.open_collection_gs2", true);
-		String defaultColDir = Gatherer.getDefaultGSCollectDirectoryPath(false); // no file separator at end
+		
+		//String collectDir = Configuration.getString("general.open_collection_gs2", true);
+		String orig_collection_path = Configuration.getString("general.open_collection_gs2", true);
+		String collectDir = Gatherer.getCollectDirectoryPath();
+		String defaultColDir = Gatherer.getDefaultGSCollectDirectoryPath(true); // with file separator at end
+		
 		// If opening a collection outside the standard GS collect folder, need
-		// to open the non-standard collect folder that the collection resides in
-		if (!collectDir.startsWith(defaultColDir + File.separator)) {
-			File collectFolder = null;
-			if(!collectDir.endsWith("gli.col")) { // then it's a collect folder
-				collectFolder = new File(collectDir);
-			} else {
-				// the filepath is a gli.col file. To get the collect folder: the 1st level
-				// up is collection folder, 2 two levels up is the containing collect folder
-				collectFolder = new File(collectDir).getParentFile().getParentFile();
-			}
-
-			// Need to deal with colgroups as well: while there's an etc/collect.cfg
-			// in the current collectFolder, move one level up
-			if(new File(collectFolder.getAbsolutePath()+File.separator+Utility.CONFIG_FILE).exists()) {
-				collectFolder = collectFolder.getParentFile();			    
-			}
-			
-			// if the collectdir from last time no longer exists this time,
-			// go back to Greenstone default collect dir
-			if(collectFolder.exists()) {
-				collectDir = collectFolder.getAbsolutePath();				
-				if(collectDir.endsWith(File.separator)) {
-					collectDir = collectDir.substring(0, collectDir.length()-1); 
-				}
-			} else {
-				collectDir = defaultColDir;				
-				// necessary for local apache web server: update gsdlsite.cfg with the reverted collectdir
-				String gsdlsitecfg = Configuration.gsdl_path + File.separator 
-					+ "cgi-bin" + File.separator + "gsdlsite.cfg";
-				Utility.updatePropertyConfigFile(gsdlsitecfg, "collecthome", collectDir); // no file separator at end
-					// if gsdlsite.cfg does not exist (if using server.exe for instance), the above method will just return
-			}
-			
-			// if we're running *server.exe* and if the current collect dir at Local Lib's startup
-			// is anything other than the default GS collect dir or if we changed back to the default 
-			// collect dir because the non-standard collectDir didn't exist, then write out 
-			// the new collectDir (minus file separator at end) to the lls site conf in use
+		// to open the non-standard collect folder that the collection resides in.
+		// Also, would have been forced to change the loaded collection--and hence collectDir--
+		// to the default coldir if orig_col_path was "" or led to a collectdir that didn't exist
+		// (in the last case, gsdlsite.cfg already corrected in Gatherer if coldir was changed).	
+		
+		if(orig_collection_path.equals("")) { // default GS collect dir path
+			return;
+		}
+		
+		if (Gatherer.open_collection_file_path != null // may be null if no_load was specified on GLI startup			
+			&& (!orig_collection_path.startsWith(collectDir) // if coldir would've been changed on startup OR if coldir is non-standard collect folder
+				|| !collectDir.equals(defaultColDir))) 
+		{			
+			// if we're running *server.exe* and if the current collect dir at Local Lib's startup is
+			// anything other than the default GS collect dir or if we changed back to the default collect 
+			// dir because the non-standard collectDir didn't exist/wasn't specified in the GLI config
+			// file, then write out the new collectDir (minus file separator at end) to the lls site conf in use
 			if (isPersistentServer) { // server.exe, so we're dealing with a local GS2			
 				put(COLLECTHOME, collectDir);
 				save();
 				lastModified = configFile.lastModified();
-			}
-			
-		} // now the correct current collect dir will get loaded when the server is started up hereafter		
+			}			
+		} // now the correct current collect dir will get loaded when the server is started up hereafter
 	}
 
