Fix moving persistent files bug.
This commit is contained in:
		| @@ -2184,39 +2184,14 @@ namespace Novell.CASA.GUI | ||||
| 			if ((sOldDirectory != null) && (sNewDirectory != null)) | ||||
| 			{ | ||||
| 				if (!sOldDirectory.Equals(sNewDirectory)) | ||||
| 				{ | ||||
| 					// get file list for .miCASAFiles | ||||
| 					string[] files = Directory.GetFiles(sOldDirectory, ".miCASA*"); | ||||
| 					if (files != null) | ||||
| 					{ | ||||
| 						string sFileSeperator; | ||||
| 						if (Common.IS_WINDOWS) | ||||
| 							sFileSeperator = "\\"; | ||||
| 						else | ||||
| 							sFileSeperator = "/"; | ||||
| 	 | ||||
| 						// first copy them to the new location | ||||
| 						foreach ( string file in files) | ||||
| 						{ | ||||
| 							string sFileName = file.Substring(file.LastIndexOf(sFileSeperator) + 1); | ||||
| 							File.Copy(file, sNewDirectory + sFileName, true);					 | ||||
| 						}				 | ||||
|  | ||||
| 						// TODO: tell our daemon/service we changed the location | ||||
| 						ChangePersistentDir cpd = new ChangePersistentDir(sOldDirectory, sNewDirectory); | ||||
| 						cpd = (ChangePersistentDir)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CHANGE_PERSIST_DIR, cpd); | ||||
|  | ||||
| 						// now delete them from the old directory | ||||
| 						foreach (string file in files) | ||||
| 						{ | ||||
| 							File.Delete(file); | ||||
| 						} | ||||
|  | ||||
| 				{				 | ||||
| 					// instruct our daemon/service to change the location | ||||
| 					ChangePersistentDir cpd = new ChangePersistentDir(sOldDirectory, sNewDirectory); | ||||
| 					cpd = (ChangePersistentDir)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CHANGE_PERSIST_DIR, cpd); | ||||
| 					if (cpd.GetErrorMessage().Equals("Success")) | ||||
| 						return true; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
|   | ||||
| @@ -143,10 +143,8 @@ public class Common | ||||
| 	public static string	CONFIG_RUN_IN_TRAY					= "RunInTray"; | ||||
| 	public static string	CONFIG_DISPLAY_CASA_MANAGER			= "DisplayCasaManagerOnClick"; | ||||
| 	public static string	CONFIG_PERSISTENT_DIRECTORY			= "PersistentDirectory"; | ||||
| 	public static string	CONFIG_PERSIST_SECRETS				= "PersistSecrets"; | ||||
| 	public static string	CONFIG_DECRYPT_USING_DESKTOP_PASS	= "DecryptUsingDesktopPassword"; | ||||
| 	public static string	CONFIG_PERSIST_SECRETS				= "PersistSecrets";	 | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	///############################################################# | ||||
| 	///CasaIcons path | ||||
|   | ||||
| @@ -111,7 +111,17 @@ namespace Novell.CASA.GUI | ||||
|  | ||||
| 			if (m_sFileSelected != null) | ||||
| 			{ | ||||
| 				if (m_iAction != FileChooser.ACTION_CHOOSE_DIR) | ||||
|  | ||||
| 				if (m_iAction == FileChooser.ACTION_CHOOSE_DIR) | ||||
| 				{ | ||||
| 					string sDirectory = m_currentDirectory + m_sFileSelected; | ||||
| 					if (sDirectory.EndsWith(m_pathSeparator)) | ||||
| 					{ | ||||
| 						sDirectory = sDirectory.Substring(0, sDirectory.Length - 1); | ||||
| 					} | ||||
| 					return sDirectory; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					// is there a filter? | ||||
| 					if (m_currentFilter.Length > 0) | ||||
| @@ -127,7 +137,8 @@ namespace Novell.CASA.GUI | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 								 | ||||
|  | ||||
| 												 | ||||
| 				return m_currentDirectory + m_sFileSelected;			 | ||||
| 				 | ||||
| 			} | ||||
|   | ||||
							
								
								
									
										11
									
								
								CASA/micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								CASA/micasad/cache/SecretStore.cs
									
									
									
									
										vendored
									
									
								
							| @@ -181,15 +181,6 @@ namespace sscs.cache | ||||
|         { | ||||
| 			CSSSLogger.DbgLog("StartPersistenceByDesktopPasswd - Called"); | ||||
|  | ||||
| 			UIPol uiPolicy = (UIPol)ICASAPol.GetPolicy(CASAPolType.UI_POL, GetUserHomeDirectory()); | ||||
| 			string sShouldUseDesktop = uiPolicy.GetConfigSetting(ConstStrings.CONFIG_DECRYPT_USING_DESKTOP_PASS);			 | ||||
| 						 | ||||
| 			if ((sShouldUseDesktop != null) && (sShouldUseDesktop.Equals("0"))) | ||||
| 			{ | ||||
| 				CSSSLogger.DbgLog("Policy set: Did not start persistent by Desktop Password"); | ||||
| 				return false; | ||||
| 			} | ||||
|  | ||||
| 			// make sure we have a Persistence Directory			 | ||||
| 			if (GetPersistenceDirectory() == null || GetPersistenceDirectory().Length < 1) | ||||
| 			{				 | ||||
| @@ -824,7 +815,7 @@ namespace sscs.cache | ||||
| 				// reset the FileWatcher | ||||
| 				if (mpWatcher != null) | ||||
| 				{ | ||||
| 					mpWatcher.pauseWatcher(); | ||||
| 					mpWatcher.pauseWatcher();					 | ||||
| 					mpWatcher = new MPFileWatcher(sNewDirectory, ConstStrings.MICASA_PASSCODE_BY_MASTERPASSWD_FILE); | ||||
| 					mpWatcher.resumeWatcher(); | ||||
| 				} | ||||
|   | ||||
| @@ -57,7 +57,8 @@ namespace sscs.common | ||||
|         override internal string GetUserHomeDir() | ||||
|         { | ||||
|             uint uid = (uint)userId.GetUID(); | ||||
| 	    Mono.Unix.UnixUserInfo uui = new Mono.Unix.UnixUserInfo(uid); | ||||
| 			Mono.Unix.UnixUserInfo uui = new Mono.Unix.UnixUserInfo(uid); | ||||
| 			userName = uui.UserName; | ||||
|             return uui.HomeDirectory;  | ||||
|         } | ||||
|          | ||||
|   | ||||
| @@ -254,17 +254,44 @@ namespace sscs.verbs | ||||
|  | ||||
| 		private WrappedObject DoChangePersistentDir(SecretStore ssStore, WrappedObject wo) | ||||
| 		{ | ||||
| 			CSSSLogger.ExecutionTrace(this); | ||||
| 			ChangePersistentDir cpd = (ChangePersistentDir)wo.GetObject(); | ||||
| 			string sOldDir = cpd.GetOldDirectory(); | ||||
| 			string sNewDir = cpd.GetNewDirectory(); | ||||
| 			 | ||||
| 			// copy all .miCASA* files to new location | ||||
| 			string[] files = Directory.GetFiles(sOldDir, ".miCASA*"); | ||||
| 			if (files != null) | ||||
| 			{ | ||||
| 				string sFileSeperator; | ||||
| #if W32				 | ||||
| 				sFileSeperator = "\\"; | ||||
| #else | ||||
| 				sFileSeperator = "/"; | ||||
| #endif | ||||
| 	 | ||||
| 				// first copy them to the new location | ||||
| 				foreach ( string file in files) | ||||
| 				{ | ||||
| 					string sFileName = file.Substring(file.LastIndexOf(sFileSeperator)); | ||||
| 					File.Copy(file, sNewDir + sFileName, true);					 | ||||
| 				}			 | ||||
|  | ||||
| 			if (ssStore.SetPeristenceDirectory(sNewDir)) | ||||
| 			{ | ||||
| 				cpd.SetErrorMessage("Success"); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				cpd.SetErrorMessage("Error: Changing directory failed"); | ||||
| 				// update filewatcher | ||||
| 				if (ssStore.SetPeristenceDirectory(sNewDir)) | ||||
| 				{ | ||||
| 					cpd.SetErrorMessage("Success");					 | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					cpd.SetErrorMessage("Error: Changing directory failed"); | ||||
| 				} | ||||
| 				 | ||||
| 				// now delete them from the old directory | ||||
| 				foreach (string file in files) | ||||
| 				{ | ||||
| 					File.Delete(file); | ||||
| 				}				 | ||||
| 			} | ||||
| 			 | ||||
| 			return wo;			 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user