Skip to content

Commit 5d1fbb7

Browse files
committed
Fix storage idempotency
1 parent c8118cb commit 5d1fbb7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/BaGet.Azure/BlobStorageService.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.IO;
33
using System.Net;
44
using System.Threading;
@@ -65,10 +65,11 @@ await blob.UploadFromStreamAsync(
6565

6666
return PutResult.Success;
6767
}
68-
catch (StorageException e) when(IsAlreadyExistsException(e))
68+
catch (StorageException e) when (IsAlreadyExistsException(e))
6969
{
7070
using (var targetStream = await blob.OpenReadAsync(cancellationToken))
7171
{
72+
content.Position = 0;
7273
return content.Matches(targetStream)
7374
? PutResult.AlreadyExists
7475
: PutResult.Conflict;

src/BaGet.Core/Services/FileStorageService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public async Task<PutResult> PutAsync(
7575
{
7676
using (var targetStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
7777
{
78+
content.Position = 0;
7879
return content.Matches(targetStream)
7980
? PutResult.AlreadyExists
8081
: PutResult.Conflict;

0 commit comments

Comments
 (0)