Skip to content

Commit

Permalink
Fix exception on calling DBCDStorage.Save() twice
Browse files Browse the repository at this point in the history
  • Loading branch information
KalopsiaTwilight committed Aug 23, 2024
1 parent cab0d12 commit 7e6de71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions DBCD.Tests/WritingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
3 changes: 2 additions & 1 deletion DBCD/DBCDStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public void Save(string filename)
foreach (var (id, record) in new SortedDictionary<int, DBCDRow>(this))
storage.Add(id, record.AsType<T>());
#endif
storage?.Save(filename);
storage.Save(filename);
storage.Clear();
}

public DBCDRow ConstructRow(int index) {
Expand Down

0 comments on commit 7e6de71

Please sign in to comment.