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

View File

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