diff --git a/DBCD.Tests/WritingTest.cs b/DBCD.Tests/WritingTest.cs index 767c1b5..873c746 100644 --- a/DBCD.Tests/WritingTest.cs +++ b/DBCD.Tests/WritingTest.cs @@ -66,6 +66,15 @@ public void TestWritingNewRowDb2WithArrayField() Assert.AreEqual(116146, outputStorage.Count); } + [TestMethod] + public void TestSavingSameStorageTwice() + { + DBCD dbcd = new(wagoDBCProvider, githubDBDProvider); + IDBCDStorage storage = dbcd.Load("AlliedRace", "9.2.7.45745"); + storage.Save(Path.Join(OutputPath, "AlliedRace.db2")); + storage.Save(Path.Join(OutputPath, "AlliedRace.db2")); + } + [TestMethod] public void TestWritingAllDB2s() { diff --git a/DBCD/DBCDStorage.cs b/DBCD/DBCDStorage.cs index 25d24b0..5f185e5 100644 --- a/DBCD/DBCDStorage.cs +++ b/DBCD/DBCDStorage.cs @@ -190,7 +190,8 @@ public void Save(string filename) foreach (var (id, record) in new SortedDictionary(this)) storage.Add(id, record.AsType()); #endif - storage?.Save(filename); + storage.Save(filename); + storage.Clear(); } public DBCDRow ConstructRow(int index) {