Browse Source

Refactor nullability

pull/165/head
Ionite 1 year ago
parent
commit
3ddadbb8f4
No known key found for this signature in database
  1. 4
      StabilityMatrix.Avalonia/DesignData/MockDownloadService.cs
  2. 5
      StabilityMatrix.Core/Services/DownloadService.cs
  3. 2
      StabilityMatrix.Core/Services/IDownloadService.cs

4
StabilityMatrix.Avalonia/DesignData/MockDownloadService.cs

@ -43,8 +43,8 @@ public class MockDownloadService : IDownloadService
return Task.FromResult(0L);
}
public Task<Stream> GetImageStreamFromUrl(string url)
public Task<Stream?> GetImageStreamFromUrl(string url)
{
return Task.FromResult(new MemoryStream(new byte[24]) as Stream);
return Task.FromResult(new MemoryStream(new byte[24]) as Stream)!;
}
}

5
StabilityMatrix.Core/Services/DownloadService.cs

@ -256,7 +256,7 @@ public class DownloadService : IDownloadService
return contentLength;
}
public async Task<Stream> GetImageStreamFromUrl(string url)
public async Task<Stream?> GetImageStreamFromUrl(string url)
{
using var client = httpClientFactory.CreateClient();
client.Timeout = TimeSpan.FromSeconds(10);
@ -270,7 +270,8 @@ public class DownloadService : IDownloadService
}
catch (Exception e)
{
return default;
logger.LogError(e, "Failed to get image stream from url {Url}", url);
return null;
}
}
}

2
StabilityMatrix.Core/Services/IDownloadService.cs

@ -27,5 +27,5 @@ public interface IDownloadService
CancellationToken cancellationToken = default
);
Task<Stream> GetImageStreamFromUrl(string url);
Task<Stream?> GetImageStreamFromUrl(string url);
}

Loading…
Cancel
Save