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

@ -2184,39 +2184,14 @@ namespace Novell.CASA.GUI
if ((sOldDirectory != null) && (sNewDirectory != null)) if ((sOldDirectory != null) && (sNewDirectory != null))
{ {
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*"); ChangePersistentDir cpd = new ChangePersistentDir(sOldDirectory, sNewDirectory);
if (files != null) cpd = (ChangePersistentDir)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CHANGE_PERSIST_DIR, cpd);
{ if (cpd.GetErrorMessage().Equals("Success"))
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);
}
return true; return true;
}
} }
} }
return false; return false;
} }

View File

@ -143,10 +143,8 @@ public class Common
public static string CONFIG_RUN_IN_TRAY = "RunInTray"; public static string CONFIG_RUN_IN_TRAY = "RunInTray";
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";
///############################################################# ///#############################################################
///CasaIcons path ///CasaIcons path

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)
@ -127,7 +137,8 @@ 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)
{ {
@ -824,7 +815,7 @@ namespace sscs.cache
// reset the FileWatcher // reset the FileWatcher
if (mpWatcher != null) if (mpWatcher != null)
{ {
mpWatcher.pauseWatcher(); mpWatcher.pauseWatcher();
mpWatcher = new MPFileWatcher(sNewDirectory, ConstStrings.MICASA_PASSCODE_BY_MASTERPASSWD_FILE); mpWatcher = new MPFileWatcher(sNewDirectory, ConstStrings.MICASA_PASSCODE_BY_MASTERPASSWD_FILE);
mpWatcher.resumeWatcher(); mpWatcher.resumeWatcher();
} }

View File

@ -57,7 +57,8 @@ namespace sscs.common
override internal string GetUserHomeDir() override internal string GetUserHomeDir()
{ {
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,17 +254,44 @@ 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);
}
if (ssStore.SetPeristenceDirectory(sNewDir)) // update filewatcher
{ if (ssStore.SetPeristenceDirectory(sNewDir))
cpd.SetErrorMessage("Success"); {
} cpd.SetErrorMessage("Success");
else }
{ else
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;