Permalink
Browse files

* Issue 701/dbe (Editing an existing bug isn't updating the XML cache…

…, probably because BE is being clever enough not to update id-cache) fixed.
  • Loading branch information...
1 parent 9a39e7a commit 9b56c5eab9b1619f4169e275fcd75d7068304a3e Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) committed Jul 16, 2012
Showing with 42 additions and 15 deletions.
  1. +1 −0 BEurtle/BEurtle.csproj
  2. +19 −15 BEurtle/BEurtlePlugin.cs
  3. +22 −0 BEurtle/LastModifiedInDirs.cs
View
1 BEurtle/BEurtle.csproj
@@ -64,6 +64,7 @@
<Compile Include="IssuesForm.Designer.cs">
<DependentUpon>IssuesForm.cs</DependentUpon>
</Compile>
+ <Compile Include="LastModifiedInDirs.cs" />
<Compile Include="OptionsDialog.cs">
<SubType>Form</SubType>
</Compile>
View
34 BEurtle/BEurtlePlugin.cs
@@ -217,27 +217,31 @@ public bool loadIssues(IWin32Window hwnd, string rootdir = null)
string xml = "unknown error";
if (rootdir.EndsWith(".xml"))
{ // This is a raw BE XML dump
- using(var fs = new StreamReader(rootdir))
+ using (var fs = new StreamReader(rootdir))
xml = fs.ReadToEnd();
VCSInfo = "Direct load of XML database";
}
- else if (parameters.CacheBEXML && File.Exists(rootdir + "\\.be\\bexml.xml") && (!File.Exists(rootdir + "\\.be\\id-cache") || File.GetLastWriteTimeUtc(rootdir + "\\.be\\bexml.xml") > File.GetLastWriteTimeUtc(rootdir + "\\.be\\id-cache")))
- { // There is a bexml.xml cache which isn't older than the id-cache, so we can use that
- using (var fs = new StreamReader(rootdir + "\\.be\\bexml.xml"))
- xml = fs.ReadToEnd();
- VCSInfo = "Used up-to-date XML cache in .be\\bexml.xml";
- }
else
{
- xml = callBEcmd(rootdir, new string[1] { arguments })[0];
- string VCSVersion = callBEcmd(rootdir, new string[1] { "vcs version" })[0];
- if (-1 == VCSVersion.IndexOf("RESULT:"))
- VCSInfo = "VCS: Error reading VCS version";
+ FileInfo idcache=new FileInfo(rootdir + "\\.be\\id-cache"), bexmlcache=new FileInfo(rootdir + "\\.be\\bexml.xml");
+ if (parameters.CacheBEXML && bexmlcache.Exists && (!idcache.Exists || bexmlcache.LastWriteTimeUtc > idcache.LastWriteTimeUtc) && nedprod.LastModifiedInDirs.FindLastModifiedSince(new DirectoryInfo(rootdir+"\\.be"), bexmlcache.LastWriteTimeUtc).Count==0)
+ { // There is a bexml.xml cache which isn't older than the id-cache nor BE repo contents, so we can use that
+ using (var fs = new StreamReader(rootdir + "\\.be\\bexml.xml"))
+ xml = fs.ReadToEnd();
+ VCSInfo = "Used up-to-date XML cache in .be\\bexml.xml";
+ }
else
- VCSInfo = "VCS: " + VCSVersion.Substring(VCSVersion.IndexOf("RESULT:") + 8);
- if (parameters.CacheBEXML && xml.StartsWith("<?xml version=\"1.0\" "))
- using (var fs = new StreamWriter(rootdir + "\\.be\\bexml.xml"))
- fs.Write(xml);
+ {
+ xml = callBEcmd(rootdir, new string[1] { arguments })[0];
+ string VCSVersion = callBEcmd(rootdir, new string[1] { "vcs version" })[0];
+ if (-1 == VCSVersion.IndexOf("RESULT:"))
+ VCSInfo = "VCS: Error reading VCS version";
+ else
+ VCSInfo = "VCS: " + VCSVersion.Substring(VCSVersion.IndexOf("RESULT:") + 8);
+ if (parameters.CacheBEXML && xml.StartsWith("<?xml version=\"1.0\" "))
+ using (var fs = new StreamWriter(rootdir + "\\.be\\bexml.xml"))
+ fs.Write(xml);
+ }
}
if (!xml.StartsWith("<?xml version=\"1.0\" "))
{
View
22 BEurtle/LastModifiedInDirs.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace nedprod
+{
+ class LastModifiedInDirs
+ {
+ public static List<FileSystemInfo> FindLastModifiedSince(DirectoryInfo path, DateTime dt, List<FileSystemInfo> ret=null)
+ {
+ if(ret==null) ret = new List<FileSystemInfo>();
+ foreach (var entry in path.GetFileSystemInfos())
+ {
+ if (entry.LastWriteTimeUtc > dt) ret.Add(entry);
+ if ((entry.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
+ FindLastModifiedSince((DirectoryInfo)entry, dt, ret);
+ }
+ return ret;
+ }
+ }
+}

0 comments on commit 9b56c5e

Please sign in to comment.