Skip to content

Commit

Permalink
Correct brace format
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceCheetah committed Jun 11, 2024
1 parent 9473c1a commit e1d2bce
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions LiteDB/Client/Storage/LiteFileStream.Read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public partial class LiteFileStream<TFileId> : Stream
public override int Read(byte[] buffer, int offset, int count)
{
if (_mode != FileAccess.Read) throw new NotSupportedException();
if (_streamPosition == Length) {
if (_streamPosition == Length)
{
return 0;
}

Expand Down Expand Up @@ -46,7 +47,8 @@ private byte[] GetChunkData(int index)

// if chunk is null there is no more chunks
byte[] result = chunk?["data"].AsBinary;
if (result != null) {
if (result != null)
{
_chunkLengths[index] = result.Length;
}
return result;
Expand All @@ -58,7 +60,8 @@ private void SetReadStreamPosition(long newPosition)
{
throw new ArgumentOutOfRangeException();
}
if (newPosition >= Length) {
if (newPosition >= Length)
{
_streamPosition = Length;
return;
}
Expand All @@ -68,11 +71,14 @@ private void SetReadStreamPosition(long newPosition)
long seekStreamPosition = 0;
int loadedChunk = _currentChunkIndex;
int newChunkIndex = 0;
while (seekStreamPosition <= _streamPosition) {
if (_chunkLengths.TryGetValue(newChunkIndex, out long length)) {
while (seekStreamPosition <= _streamPosition)
{
if (_chunkLengths.TryGetValue(newChunkIndex, out long length))
{
seekStreamPosition += length;
}
else {
else
{
loadedChunk = newChunkIndex;
_currentChunkData = GetChunkData(newChunkIndex);
seekStreamPosition += _currentChunkData.Length;
Expand All @@ -83,7 +89,8 @@ private void SetReadStreamPosition(long newPosition)
seekStreamPosition -= _chunkLengths[newChunkIndex];
_positionInChunk = (int)(_streamPosition - seekStreamPosition);
_currentChunkIndex = newChunkIndex;
if (loadedChunk != _currentChunkIndex) {
if (loadedChunk != _currentChunkIndex)
{
_currentChunkData = GetChunkData(_currentChunkIndex);
}
}
Expand Down

0 comments on commit e1d2bce

Please sign in to comment.