Skip to content

Commit

Permalink
Fixes minio impl
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Jan 5, 2024
1 parent c6d0077 commit b922086
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Foundatio.Minio/Storage/MinioFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public async Task<FileSpec> GetFileInfoAsync(string path)
try
{
var metadata = await _client.StatObjectAsync(new StatObjectArgs().WithBucket(_bucket).WithObject(normalizedPath)).AnyContext();
if (metadata.ExtraHeaders.TryGetValue("X-Minio-Error-Code", out string errorCode) && (String.Equals(errorCode, "NoSuchBucket") || String.Equals(errorCode, "NoSuchKey")))
return null;

return new FileSpec
{
Path = normalizedPath,
Expand Down Expand Up @@ -135,7 +138,11 @@ public async Task<bool> ExistsAsync(string path)

try
{
return await _client.StatObjectAsync(new StatObjectArgs().WithBucket(_bucket).WithObject(normalizedPath)).AnyContext() != null;
var metadata = await _client.StatObjectAsync(new StatObjectArgs().WithBucket(_bucket).WithObject(normalizedPath)).AnyContext();
if (metadata.ExtraHeaders.TryGetValue("X-Minio-Error-Code", out string errorCode) && (String.Equals(errorCode, "NoSuchBucket") || String.Equals(errorCode, "NoSuchKey")))
return false;

return true;
}
catch (Exception ex) when (ex is ObjectNotFoundException or BucketNotFoundException)
{
Expand Down

0 comments on commit b922086

Please sign in to comment.