Skip to content

Commit

Permalink
进一步加强Txt删除最后一条数据时的并发处理。
Browse files Browse the repository at this point in the history
  • Loading branch information
cyq1162 committed Oct 23, 2016
1 parent 9d501d6 commit ce3d53e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Action/NoSqlAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private MDataTable Table
else if (_tableList.ContainsKey(_FileFullName))
{
_Table = _tableList[_FileFullName];
if (_Table.Rows.Count == 0)
if (_Table.Rows.Count == 0 && !isDeleteAll)
{
if (_maxID.ContainsKey(_FileFullName))
{
Expand Down Expand Up @@ -270,6 +270,7 @@ public bool Delete(object where)
int count = 0;
return Delete(where, out count);
}
private bool isDeleteAll = false;
internal bool Delete(object where, out int count)
{
count = -1;
Expand All @@ -283,7 +284,7 @@ internal bool Delete(object where, out int count)
count = rowList.Count;
if (count > 0)
{
bool isDeleteAll = count == Table.Rows.Count;
isDeleteAll = count == Table.Rows.Count;
for (int i = rowList.Count - 1; i >= 0; i--)
{
try
Expand Down Expand Up @@ -525,7 +526,6 @@ private void Save()
try
{
string text = string.Empty;

if (string.IsNullOrEmpty(text))
{
text = _DalType == DalType.Txt ? Table.ToJson(false, true).Replace("},{", "},\r\n{").Trim('[', ']') : Table.ToXml();
Expand All @@ -539,6 +539,7 @@ private void Save()

IOHelper.Write(_FileFullName, text);
tryAgainCount = 0;
isDeleteAll = false;
}
catch
{
Expand Down

0 comments on commit ce3d53e

Please sign in to comment.