diff --git a/src/OrigoDB.Core.UnitTests/SnapshotTests.cs b/src/OrigoDB.Core.UnitTests/SnapshotTests.cs
index 6fd201b..c181fb8 100644
--- a/src/OrigoDB.Core.UnitTests/SnapshotTests.cs
+++ b/src/OrigoDB.Core.UnitTests/SnapshotTests.cs
@@ -1,5 +1,7 @@
-using System.Linq;
+using System;
+using System.Linq;
using NUnit.Framework;
+using OrigoDB.Core.Storage;
namespace OrigoDB.Core.Test
{
@@ -26,5 +28,14 @@ public void Snapshots_are_numbered_correctly()
Assert.AreEqual(2, store.Snapshots.Count());
}
+
+ [Test]
+ public void Entry_id_is_extracted_from_snapshot_filename()
+ {
+ var dt = DateTime.Now;
+ Snapshot ss = FileSnapshot.FromFileInfo("000467000.snapshot", dt);
+ Assert.AreEqual(dt,ss.Created);
+ Assert.AreEqual(467000, ss.LastEntryId);
+ }
}
}
\ No newline at end of file
diff --git a/src/OrigoDB.Core/OrigoDB.Core.csproj b/src/OrigoDB.Core/OrigoDB.Core.csproj
index a9fda39..06a4c86 100644
--- a/src/OrigoDB.Core/OrigoDB.Core.csproj
+++ b/src/OrigoDB.Core/OrigoDB.Core.csproj
@@ -85,6 +85,7 @@
+
diff --git a/src/OrigoDB.Core/Storage/FileSnapshot.cs b/src/OrigoDB.Core/Storage/FileSnapshot.cs
new file mode 100644
index 0000000..fd6c2f5
--- /dev/null
+++ b/src/OrigoDB.Core/Storage/FileSnapshot.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Text.RegularExpressions;
+
+namespace OrigoDB.Core.Storage
+{
+ public class FileSnapshot : Snapshot
+ {
+ public string Name { get { return ToString(); } }
+
+
+ public FileSnapshot(DateTime created, ulong lastEntryId) : base(created, lastEntryId)
+ {
+
+ }
+
+ const string Pattern = @"^(?\d{9}).snapshot$";
+
+ readonly private static Regex _parser = new Regex(Pattern);
+
+ public static FileSnapshot FromFileInfo(string fileName, DateTime created)
+ {
+ Match m = _parser.Match(fileName);
+ if (!m.Success) throw new ArgumentException("Invalid snapshot filename");
+ ulong entryNr = m.Groups["entryNr"].Value.ParsePadded();
+ return new FileSnapshot(created, entryNr);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("{0:000000000}.snapshot", LastEntryId);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/OrigoDB.Core/Storage/FileStore.cs b/src/OrigoDB.Core/Storage/FileStore.cs
index 854bce3..627854f 100644
--- a/src/OrigoDB.Core/Storage/FileStore.cs
+++ b/src/OrigoDB.Core/Storage/FileStore.cs
@@ -206,7 +206,7 @@ protected override IEnumerable ReadSnapshotMetaData()
foreach (var file in Directory.GetFiles(_config.Location.OfSnapshots, "*.snapshot"))
{
var fileInfo = new FileInfo(file);
- snapshots.Add(FileSnapshot.FromFileInfo(fileInfo));
+ snapshots.Add(FileSnapshot.FromFileInfo(fileInfo.Name, fileInfo.CreationTime));
}
snapshots.Sort((a, b) => a.LastEntryId.CompareTo(b.LastEntryId));
diff --git a/src/OrigoDB.Core/Storage/Snapshot.cs b/src/OrigoDB.Core/Storage/Snapshot.cs
index f6407c0..d235b4c 100644
--- a/src/OrigoDB.Core/Storage/Snapshot.cs
+++ b/src/OrigoDB.Core/Storage/Snapshot.cs
@@ -1,13 +1,8 @@
using System;
-using System.Text.RegularExpressions;
-using System.IO;
namespace OrigoDB.Core.Storage
{
- ///
- ///
- ///
public class Snapshot
{
@@ -29,31 +24,4 @@ public Snapshot(DateTime created, ulong lastEntryId)
LastEntryId = lastEntryId;
}
}
-
- public class FileSnapshot : Snapshot
- {
- public string Name { get { return ToString(); } }
-
-
- public FileSnapshot(DateTime created, ulong lastEntryId) : base(created, lastEntryId)
- {
-
- }
-
-
- const string Pattern = @"^(?\d{9}).snapshot$";
- private static Regex _parser = new Regex(Pattern);
- public static FileSnapshot FromFileInfo(FileInfo fileInfo)
- {
- Match m = _parser.Match(fileInfo.Name);
- if (!m.Success) throw new ArgumentException("Invalid snapshot filename");
- ulong entryNr = m.Groups["entryNr"].Value.ParsePadded();
- return new FileSnapshot(fileInfo.CreationTime, entryNr);
- }
-
- public override string ToString()
- {
- return String.Format("{0:000000000}.snapshot", LastEntryId);
- }
- }
}
diff --git a/src/OrigoDB.Core/Utilities/Extensions.cs b/src/OrigoDB.Core/Utilities/Extensions.cs
index fbcbeb0..03af333 100644
--- a/src/OrigoDB.Core/Utilities/Extensions.cs
+++ b/src/OrigoDB.Core/Utilities/Extensions.cs
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Collections.Specialized;
namespace OrigoDB.Core
{
diff --git a/src/SharedAssemblyInfo.cs b/src/SharedAssemblyInfo.cs
index edb1b89..5666cd4 100644
--- a/src/SharedAssemblyInfo.cs
+++ b/src/SharedAssemblyInfo.cs
@@ -14,8 +14,8 @@
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("0.12.0")]
-[assembly: AssemblyFileVersion("0.12.0")]
+[assembly: AssemblyVersion("0.12.1")]
+[assembly: AssemblyFileVersion("0.12.1")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OrigoDB.Enterprise")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OrigoDB.Core.Test")]