Skip to content

Commit 3a1fcf0

Browse files
committed
Better safe than sorry
1 parent 760774d commit 3a1fcf0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

LiteDB/Engine/Disk/DiskService.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.IO;
55
using System.Threading;
6+
using LiteDB.Utils;
67
using static LiteDB.Constants;
78

89
namespace LiteDB.Engine
@@ -348,14 +349,16 @@ public void Dispose()
348349
// can change file size
349350
var delete = _logFactory.Exists() && _logPool.Writer.Value.Length == 0;
350351

352+
var tc = new TryCatch();
353+
351354
// dispose Stream pools
352-
_dataPool.Dispose();
353-
_logPool.Dispose();
355+
tc.Catch(() => _dataPool.Dispose());
356+
tc.Catch(() => _logPool.Dispose());
354357

355-
if (delete) _logFactory.Delete();
358+
if (delete) tc.Catch(() => _logFactory.Delete());
356359

357360
// other disposes
358-
_cache.Dispose();
361+
tc.Catch(() => _cache.Dispose());
359362
}
360363
}
361364
}

0 commit comments

Comments
 (0)