Skip to content

Commit

Permalink
chore: avoid conflict on zip download from s3 (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemaitre-aneo authored Jul 30, 2024
2 parents da71390 + 7a70f3a commit 389462f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion Worker/src/Common/Adapter/S3Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ public async Task DownloadFileAsync(string fileName)
});
var stream2 = new BufferedStream(r.ResponseStream);

var materializedFileName = fileName + Guid.NewGuid();

var file = new FileStream(Path.Combine(LocalZipDir,
fileName),
materializedFileName),
FileMode.Create,
FileAccess.Write);
try
Expand Down Expand Up @@ -133,5 +135,10 @@ public async Task DownloadFileAsync(string fileName)

throw new Exception("Error occurred: " + amazonS3Exception.Message);
}

File.Move(Path.Combine(LocalZipDir,
materializedFileName),
Path.Combine(LocalZipDir,
fileName));
}
}

0 comments on commit 389462f

Please sign in to comment.