From 92075e8aff87440c5323d1e8f30a22aebcefd1e3 Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Thu, 27 Oct 2005 20:33:35 +0000 Subject: [PATCH] Better handle .miCASA persistent file --- c_micasad/lss/LocalStorage.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/c_micasad/lss/LocalStorage.cs b/c_micasad/lss/LocalStorage.cs index 9b4ffc43..694fd4a3 100644 --- a/c_micasad/lss/LocalStorage.cs +++ b/c_micasad/lss/LocalStorage.cs @@ -103,8 +103,18 @@ namespace sscs.lss try { string fileName = userStore.GetPersistenceFilePath(); - if(!File.Exists(fileName)) - return null; + if(!File.Exists(fileName)) + { + // check for tmp file + if (File.Exists(fileName+".tmp")) + File.Move(fileName+".tmp", fileName); + else + return null; + } + + // delete tmp file if there + if (File.Exists(fileName+".tmp")) + File.Delete(fileName+".tmp"); byte[] baPasscode = CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath()); if( null == baPasscode ) @@ -398,6 +408,9 @@ namespace sscs.lss // rename existing file if(File.Exists(fileName)) { + if (File.Exists(fileName+".tmp")) + File.Delete(fileName+".tmp"); + File.Move(fileName, fileName+".tmp"); }