Bug 178796. MPFileWatcher created a race condition on deletion of files.

This commit is contained in:
Jim Norman 2006-07-11 22:10:16 +00:00
parent d146250ece
commit 0408acc206
2 changed files with 19 additions and 18 deletions

View File

@ -37,7 +37,7 @@ namespace sscs.init
public static void Install()
{
System.Diagnostics.Debug.WriteLine("CASA: attempting to register lcredmgr");
System.Diagnostics.Trace.WriteLine("CASA: attempting to register lcredmgr");
string sExePath = GetRegSvrPath();
if (sExePath != null)
{
@ -51,7 +51,7 @@ namespace sscs.init
public static void Uninstall()
{
System.Diagnostics.Debug.WriteLine("CASA: attempting to unregister lcredmgr");
System.Diagnostics.Trace.WriteLine("CASA: attempting to unregister lcredmgr");
string sExePath = GetRegSvrPath();
if (sExePath != null)
{
@ -81,11 +81,11 @@ namespace sscs.init
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myProcess.WaitForExit();
System.Diagnostics.Debug.WriteLine("Completed " + myProcess.ExitCode.ToString());
System.Diagnostics.Trace.WriteLine("Completed " + myProcess.ExitCode.ToString());
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
System.Diagnostics.Trace.WriteLine(e.ToString());
}
}
}
@ -103,12 +103,12 @@ namespace sscs.init
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find regsvr32.exe");
System.Diagnostics.Trace.WriteLine("Did not find regsvr32.exe");
}
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find System path");
System.Diagnostics.Trace.WriteLine("Did not find System path");
}
return null;
@ -125,12 +125,12 @@ namespace sscs.init
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find lcredmgr.dll");
System.Diagnostics.Trace.WriteLine("Did not find lcredmgr.dll");
}
}
else
{
System.Diagnostics.Debug.WriteLine("Did not find path to [ProgramFiles]");
System.Diagnostics.Trace.WriteLine("Did not find path to [ProgramFiles]");
}
return null;

View File

@ -432,11 +432,11 @@ namespace sscs.crypto
CryptoStream csEncrypt = null;
try
{
if(File.Exists(fileName))
File.Delete(fileName);
// NOTE: removed the delete call because the MPFileWatcher would replace it.
//if(File.Exists(fileName))
// File.Delete(fileName);
byte[] baKey = Generate16ByteKeyFromString(passwd, null, false);
//Get an encryptor.
RijndaelManaged myRijndael = new RijndaelManaged();
ICryptoTransform encryptor;
@ -445,18 +445,18 @@ namespace sscs.crypto
//Encrypt the data to a file
fsEncrypt = new FileStream(fileName,FileMode.Create);
// make hidden
File.SetAttributes(fileName, FileAttributes.Hidden);
csEncrypt = new CryptoStream(fsEncrypt, encryptor,
CryptoStreamMode.Write);
//Write all data to the crypto stream and flush it.
//Write all data to the crypto stream and flush it.
csEncrypt.Write(baMasterPasscode, 0, baMasterPasscode.Length);
csEncrypt.FlushFinalBlock();
csEncrypt.Close();
fsEncrypt.Close();
// make hidden
File.SetAttributes(fileName, FileAttributes.Hidden);
}
catch(Exception e)
{
@ -668,8 +668,9 @@ namespace sscs.crypto
try
{
if (File.Exists(sFileName + ".IV"))
File.Delete(sFileName + ".IV");
// NOTE: removed the delete call because the MPFileWatcher would replace it.
//if (File.Exists(sFileName + ".IV"))
// File.Delete(sFileName + ".IV");
// now save this
FileStream fs = new FileStream(sFileName + ".IV", FileMode.Create);