diff --git a/LiteDB/Engine/Engine/Upgrade.cs b/LiteDB/Engine/Engine/Upgrade.cs index c36a94373..30beffa6d 100644 --- a/LiteDB/Engine/Engine/Upgrade.cs +++ b/LiteDB/Engine/Engine/Upgrade.cs @@ -23,17 +23,19 @@ private void TryUpgrade() // if file not exists, just exit if (!File.Exists(filename)) return; - var buffer = _bufferPool.Rent(1024); + const int bufferSize = 1024; + var buffer = _bufferPool.Rent(bufferSize); + using (var stream = new FileStream( _settings.Filename, FileMode.Open, FileAccess.Read, - FileShare.Read, 1024)) + FileShare.Read, bufferSize)) { stream.Position = 0; - stream.Read(buffer, 0, buffer.Length); + stream.Read(buffer, 0, bufferSize); if (FileReaderV7.IsVersion(buffer) == false) return; }