Skip to content

Commit

Permalink
Fix nits suggested by rider
Browse files Browse the repository at this point in the history
  • Loading branch information
inthemedium committed Apr 19, 2024
1 parent eb348a2 commit 3c6399c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
13 changes: 6 additions & 7 deletions src/SleetLib/FileSystem/AzureBlobLease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ public class AzureBlobLease : IDisposable
{
private static readonly TimeSpan _leaseTime = new TimeSpan(0, 1, 0);
private readonly BlobClient _blob;
private readonly string _leaseId;

public AzureBlobLease(BlobClient blob)
{
_blob = blob;
_leaseId = Guid.NewGuid().ToString();
LeaseId = Guid.NewGuid().ToString();
}

public string LeaseId => _leaseId;
public string LeaseId { get; }

/// <summary>
/// Makes a single attempt to get a lease.
Expand All @@ -28,21 +27,21 @@ public async Task<bool> GetLease()

try
{
actualLease = (await _blob.GetBlobLeaseClient(_leaseId).AcquireAsync(_leaseTime)).Value.LeaseId;
actualLease = (await _blob.GetBlobLeaseClient(LeaseId).AcquireAsync(_leaseTime)).Value.LeaseId;
}
catch (Exception ex)
{
Debug.Fail($"GetLease failed: {ex}");
}

return StringComparer.Ordinal.Equals(_leaseId, actualLease);
return StringComparer.Ordinal.Equals(LeaseId, actualLease);
}

public async Task Renew()
{
try
{
await _blob.GetBlobLeaseClient(_leaseId).RenewAsync();
await _blob.GetBlobLeaseClient(LeaseId).RenewAsync();
}
catch (Exception ex)
{
Expand All @@ -62,7 +61,7 @@ public void Release()
try
{

_blob.GetBlobLeaseClient(_leaseId).ReleaseAsync().Wait(TimeSpan.FromSeconds(60));
_blob.GetBlobLeaseClient(LeaseId).ReleaseAsync().Wait(TimeSpan.FromSeconds(60));
}
catch (Exception ex)
{
Expand Down
8 changes: 5 additions & 3 deletions src/SleetLib/FileSystem/AzureFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal AzureFile(AzureFileSystem fileSystem, Uri rootPath, Uri displayPath, Fi

protected override async Task CopyFromSource(ILogger log, CancellationToken token)
{
if (await _blob.ExistsAsync())
if (await _blob.ExistsAsync(token))
{
log.LogVerbose($"GET {_blob.Uri.AbsoluteUri}");

Expand Down Expand Up @@ -58,8 +58,10 @@ protected override async Task CopyToSource(ILogger log, CancellationToken token)
using (var cache = LocalCacheFile.OpenRead())
{
Stream writeStream = cache;
var blobHeaders = new BlobHttpHeaders();
blobHeaders.CacheControl = "no-store";
var blobHeaders = new BlobHttpHeaders
{
CacheControl = "no-store"
};

if (_blob.Uri.AbsoluteUri.EndsWith(".nupkg", StringComparison.Ordinal))

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types

Check failure on line 66 in src/SleetLib/FileSystem/AzureFile.cs

View workflow job for this annotation

GitHub Actions / build-linux

Type 'AzureFile' already defines a member called 'CopyFromSource' with the same parameter types
{
Expand Down
6 changes: 2 additions & 4 deletions src/SleetLib/FileSystem/AzureFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class AzureFileSystem : FileSystemBase
{
public static readonly string AzureEmptyConnectionString = "DefaultEndpointsProtocol=https;AccountName=;AccountKey=;BlobEndpoint=";

private readonly BlobServiceClient _blobServiceClient;
private readonly BlobContainerClient _container;

public AzureFileSystem(LocalCache cache, Uri root, BlobServiceClient blobServiceClient, string container)
Expand All @@ -19,8 +18,7 @@ public AzureFileSystem(LocalCache cache, Uri root, BlobServiceClient blobService
public AzureFileSystem(LocalCache cache, Uri root, Uri baseUri, BlobServiceClient blobServiceClient, string container, string feedSubPath = null)
: base(cache, root, baseUri, feedSubPath)
{
_blobServiceClient = blobServiceClient;
_container = _blobServiceClient.GetBlobContainerClient(container);
_container = blobServiceClient.GetBlobContainerClient(container);

var containerUri = UriUtility.EnsureTrailingSlash(_container.Uri);
var expectedPath = UriUtility.EnsureTrailingSlash(root);
Expand Down Expand Up @@ -63,7 +61,7 @@ public override async Task<bool> Validate(ILogger log, CancellationToken token)
{
log.LogInformation($"Verifying {_container.Uri.AbsoluteUri} exists.");

if (await _container.ExistsAsync())
if (await _container.ExistsAsync(token))
{
log.LogInformation($"Found {_container.Uri.AbsoluteUri}");
}
Expand Down

0 comments on commit 3c6399c

Please sign in to comment.