Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Rambalac committed Mar 27, 2017
1 parent 0c73876 commit 379545c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 5 additions & 6 deletions amazon-clouddrive-dokan/SmallFileBlockStream.cs
Expand Up @@ -120,14 +120,13 @@ public override async Task<int> Read(long position, byte[] buffer, int offset, i
try
{
stream.Position = position;
if (downloader == null)
var toread = (int)Math.Min(count, (downloader?.Downloaded ?? item.Length) - position);
if (toread < 0)
{
red = await stream.ReadAsync(buffer, offset, (int)Math.Min(count, item.Length - position), timeoutcancel.Token);
}
else
{
red = await stream.ReadAsync(buffer, offset, (int)Math.Min(count, downloader.Downloaded - position), timeoutcancel.Token);
Log.ErrorTrace("toread less than zero:" + item.Name);
}

red = await stream.ReadAsync(buffer, offset, toread, timeoutcancel.Token);
}
finally
{
Expand Down
4 changes: 4 additions & 0 deletions amazon-clouddrive-dokanTests/Cloud.DokanNet.Tests.csproj
Expand Up @@ -100,6 +100,10 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AmazonCloudDriveApi\AmazonCloudDriveApi\AmazonCloudDriveApi.csproj">
<Project>{2C611335-3D92-492F-B3EB-2CF3955F63A1}</Project>
<Name>AmazonCloudDriveApi</Name>
</ProjectReference>
<ProjectReference Include="..\amazon-clouddrive-dokan\Cloud.DokanNet.csproj">
<Project>{213AA535-DB16-4CF9-B3F1-324FF9347F8D}</Project>
<Name>Cloud.DokanNet</Name>
Expand Down

0 comments on commit 379545c

Please sign in to comment.