private void PostRunCleanup() { try { string svnSimpleFolder = Path.Combine(_gitSvnCacheDirectory, "svn.simple"); if (!Directory.Exists(svnSimpleFolder)) { return; } var cacheFiles = Directory.GetFiles(svnSimpleFolder); if (cacheFiles.Length > 0) { MessageDisplayer.Show("Recoverying cached credentials..."); foreach (var cf in cacheFiles) { if (string.IsNullOrEmpty(Path.GetExtension(cf))) { continue; } var fileNameWithoutExt = Path.GetFileNameWithoutExtension(cf); var cacheFilePath = Path.Combine(svnSimpleFolder, fileNameWithoutExt); if (!File.Exists(cacheFilePath)) { File.Move(cf, cacheFilePath); } else { // A new cache file with the same hash generated. // No need to recover the old one. File.Delete(cf); } } MessageDisplayer.Show("Cached credentials recovered"); } } catch (IOException ex) { MessageDisplayer.Show("Failed to recover the cached credentials."); Log(ex.ToString()); } }
private void PreRunPrepare() { try { string svnSimpleFolder = Path.Combine(_gitSvnCacheDirectory, "svn.simple"); if (!Directory.Exists(svnSimpleFolder)) { return; } var cacheFiles = Directory.GetFiles(svnSimpleFolder); if (cacheFiles.Length > 0) { MessageDisplayer.Show("Temporarily disabling the cached credentials..."); foreach (var cf in cacheFiles) { if (string.IsNullOrEmpty(Path.GetExtension(cf))) { string newFileName = cf + ".svn2gitnet"; if (File.Exists(newFileName)) { File.Delete(newFileName); } File.Move(cf, newFileName); } } MessageDisplayer.Show("The cached credentials are disabled."); } } catch (IOException ex) { MessageDisplayer.Show("Failed to disable the cached credentials. We'll use the cached credentials for further actions."); Log(ex.ToString()); } }
// ---------------- Functions ---------------- protected void ShowMessageIfPossible(string message) { MessageDisplayer?.Show(message); }