Improve FileWatcher functionality.

This commit is contained in:
Jim Norman 2006-07-12 15:23:09 +00:00
parent 0408acc206
commit 9fd0d5b8f0
5 changed files with 28 additions and 11 deletions

View File

@ -730,14 +730,26 @@ namespace sscs.cache
byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingMasterPasswd(sCurrentPWD, sMasterFilePath, false); byte[] baPasscode = CASACrypto.GetMasterPasscodeUsingMasterPasswd(sCurrentPWD, sMasterFilePath, false);
if (baPasscode != null) if (baPasscode != null)
{ {
mpWatcher.pauseWatcher(); PauseFileWatcher();
CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, sNewPWD, sMasterFilePath); CASACrypto.EncryptAndStoreMasterPasscodeUsingString(baPasscode, sNewPWD, sMasterFilePath);
mpWatcher.resumeWatcher(); ResumeFileWatcher();
return true; return true;
} }
return false; return false;
} }
internal void PauseFileWatcher()
{
if (mpWatcher != null)
mpWatcher.pauseWatcher();
}
internal void ResumeFileWatcher()
{
if (mpWatcher != null)
mpWatcher.resumeWatcher();
}
internal string GetDesktopPasswd() internal string GetDesktopPasswd()
{ {
try try

View File

@ -431,10 +431,9 @@ namespace sscs.crypto
FileStream fsEncrypt = null; FileStream fsEncrypt = null;
CryptoStream csEncrypt = null; CryptoStream csEncrypt = null;
try try
{ {
// NOTE: removed the delete call because the MPFileWatcher would replace it. if(File.Exists(fileName))
//if(File.Exists(fileName)) File.Delete(fileName);
// File.Delete(fileName);
byte[] baKey = Generate16ByteKeyFromString(passwd, null, false); byte[] baKey = Generate16ByteKeyFromString(passwd, null, false);
//Get an encryptor. //Get an encryptor.
@ -667,10 +666,9 @@ namespace sscs.crypto
byte[] baIV = theRiManaged.IV; byte[] baIV = theRiManaged.IV;
try try
{ {
// NOTE: removed the delete call because the MPFileWatcher would replace it. if (File.Exists(sFileName + ".IV"))
//if (File.Exists(sFileName + ".IV")) File.Delete(sFileName + ".IV");
// File.Delete(sFileName + ".IV");
// now save this // now save this
FileStream fs = new FileStream(sFileName + ".IV", FileMode.Create); FileStream fs = new FileStream(sFileName + ".IV", FileMode.Create);

View File

@ -122,6 +122,7 @@ namespace sscs.verbs
{ {
SecretStore ssStore = SessionManager.CreateUserSession(userId); SecretStore ssStore = SessionManager.CreateUserSession(userId);
ssStore.PauseFileWatcher();
try try
{ {
@ -230,7 +231,7 @@ namespace sscs.verbs
wo.SetError(constants.RetCodes.FAILURE, e.ToString()); wo.SetError(constants.RetCodes.FAILURE, e.ToString());
} }
ssStore.ResumeFileWatcher();
return wo; return wo;
} }

View File

@ -87,10 +87,12 @@ namespace sscs.verbs
{ {
SecretStore ssStore = null; SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId); ssStore = SessionManager.GetUserSecretStore(userId);
ssStore.PauseFileWatcher();
if(ssStore.SetMasterPasscode(passcode)) if(ssStore.SetMasterPasscode(passcode))
retCode = IPCRetCodes.SSCS_REPLY_SUCCESS; retCode = IPCRetCodes.SSCS_REPLY_SUCCESS;
else else
retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED; retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED;
ssStore.ResumeFileWatcher();
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {

View File

@ -95,10 +95,14 @@ namespace sscs.verbs
{ {
SecretStore ssStore = null; SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId); ssStore = SessionManager.GetUserSecretStore(userId);
ssStore.PauseFileWatcher();
if(ssStore.SetMasterPassword(passwd)) if(ssStore.SetMasterPassword(passwd))
retCode = IPCRetCodes.SSCS_REPLY_SUCCESS; retCode = IPCRetCodes.SSCS_REPLY_SUCCESS;
else else
retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED; retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED;
ssStore.ResumeFileWatcher();
} }
catch(UserNotInSessionException) catch(UserNotInSessionException)
{ {