Fix moving persistent files bug.

This commit is contained in:
Jim Norman 2006-09-20 20:43:29 +00:00
parent 7d20a31bc0
commit 03ca6a4a03
6 changed files with 56 additions and 53 deletions

View File

@ -2185,38 +2185,13 @@ namespace Novell.CASA.GUI
{ {
if (!sOldDirectory.Equals(sNewDirectory)) if (!sOldDirectory.Equals(sNewDirectory))
{ {
// get file list for .miCASAFiles // instruct our daemon/service to change the location
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); ChangePersistentDir cpd = new ChangePersistentDir(sOldDirectory, sNewDirectory);
cpd = (ChangePersistentDir)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CHANGE_PERSIST_DIR, cpd); cpd = (ChangePersistentDir)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CHANGE_PERSIST_DIR, cpd);
if (cpd.GetErrorMessage().Equals("Success"))
// now delete them from the old directory
foreach (string file in files)
{
File.Delete(file);
}
return true; return true;
} }
} }
}
return false; return false;
} }

View File

@ -144,8 +144,6 @@ public class Common
public static string CONFIG_DISPLAY_CASA_MANAGER = "DisplayCasaManagerOnClick"; public static string CONFIG_DISPLAY_CASA_MANAGER = "DisplayCasaManagerOnClick";
public static string CONFIG_PERSISTENT_DIRECTORY = "PersistentDirectory"; public static string CONFIG_PERSISTENT_DIRECTORY = "PersistentDirectory";
public static string CONFIG_PERSIST_SECRETS = "PersistSecrets"; public static string CONFIG_PERSIST_SECRETS = "PersistSecrets";
public static string CONFIG_DECRYPT_USING_DESKTOP_PASS = "DecryptUsingDesktopPassword";
///############################################################# ///#############################################################

View File

@ -111,7 +111,17 @@ namespace Novell.CASA.GUI
if (m_sFileSelected != null) 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? // is there a filter?
if (m_currentFilter.Length > 0) if (m_currentFilter.Length > 0)
@ -128,6 +138,7 @@ namespace Novell.CASA.GUI
} }
} }
return m_currentDirectory + m_sFileSelected; return m_currentDirectory + m_sFileSelected;
} }

View File

@ -181,15 +181,6 @@ namespace sscs.cache
{ {
CSSSLogger.DbgLog("StartPersistenceByDesktopPasswd - Called"); 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 // make sure we have a Persistence Directory
if (GetPersistenceDirectory() == null || GetPersistenceDirectory().Length < 1) if (GetPersistenceDirectory() == null || GetPersistenceDirectory().Length < 1)
{ {

View File

@ -58,6 +58,7 @@ namespace sscs.common
{ {
uint uid = (uint)userId.GetUID(); 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; return uui.HomeDirectory;
} }

View File

@ -254,10 +254,30 @@ namespace sscs.verbs
private WrappedObject DoChangePersistentDir(SecretStore ssStore, WrappedObject wo) private WrappedObject DoChangePersistentDir(SecretStore ssStore, WrappedObject wo)
{ {
CSSSLogger.ExecutionTrace(this);
ChangePersistentDir cpd = (ChangePersistentDir)wo.GetObject(); ChangePersistentDir cpd = (ChangePersistentDir)wo.GetObject();
string sOldDir = cpd.GetOldDirectory(); string sOldDir = cpd.GetOldDirectory();
string sNewDir = cpd.GetNewDirectory(); 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);
}
// update filewatcher
if (ssStore.SetPeristenceDirectory(sNewDir)) if (ssStore.SetPeristenceDirectory(sNewDir))
{ {
cpd.SetErrorMessage("Success"); cpd.SetErrorMessage("Success");
@ -267,6 +287,13 @@ namespace sscs.verbs
cpd.SetErrorMessage("Error: Changing directory failed"); cpd.SetErrorMessage("Error: Changing directory failed");
} }
// now delete them from the old directory
foreach (string file in files)
{
File.Delete(file);
}
}
return wo; return wo;
} }