Browse Source

fix artwork upload on windows (#518)

* update changelog for release v0.3.1-alpha [no ci]

* fix artwork upload on windows
pull/519/head
Jason Dove 5 years ago committed by GitHub
parent
commit
848795af32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      CHANGELOG.md
  2. 17
      ErsatzTV.Infrastructure/Images/ImageCache.cs

7
CHANGELOG.md

@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix artwork upload on Windows
## [0.3.1-alpha] - 2021-11-30
### Fixed
- Fix song page links in UI
- Show song artist in playout detail
- Include song artist and cover art in channel guide (xmltv)
@ -835,7 +839,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -835,7 +839,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Initial release to facilitate testing outside of Docker.
[Unreleased]: https://github.com/jasongdove/ErsatzTV/compare/v0.3.0-alpha...HEAD
[Unreleased]: https://github.com/jasongdove/ErsatzTV/compare/v0.3.1-alpha...HEAD
[0.3.1-alpha]: https://github.com/jasongdove/ErsatzTV/compare/v0.3.0-alpha...v0.3.1-alpha
[0.3.0-alpha]: https://github.com/jasongdove/ErsatzTV/compare/v0.2.5-alpha...v0.3.0-alpha
[0.2.5-alpha]: https://github.com/jasongdove/ErsatzTV/compare/v0.2.4-alpha...v0.2.5-alpha
[0.2.4-alpha]: https://github.com/jasongdove/ErsatzTV/compare/v0.2.3-alpha...v0.2.4-alpha

17
ErsatzTV.Infrastructure/Images/ImageCache.cs

@ -66,8 +66,11 @@ namespace ErsatzTV.Infrastructure.Images @@ -66,8 +66,11 @@ namespace ErsatzTV.Infrastructure.Images
try
{
string tempFileName = _tempFilePool.GetNextTempFile(TempFileCategory.CachedArtwork);
await using var fs = new FileStream(tempFileName, FileMode.OpenOrCreate);
await stream.CopyToAsync(fs);
// ReSharper disable once UseAwaitUsing
using (var fs = new FileStream(tempFileName, FileMode.OpenOrCreate, FileAccess.Write))
{
await stream.CopyToAsync(fs);
}
byte[] hash = await ComputeFileHash(tempFileName);
string hex = BitConverter.ToString(hash).Replace("-", string.Empty);
string subfolder = hex[..2];
@ -100,9 +103,13 @@ namespace ErsatzTV.Infrastructure.Images @@ -100,9 +103,13 @@ namespace ErsatzTV.Infrastructure.Images
private static async Task<byte[]> ComputeFileHash(string fileName)
{
using var md5 = MD5.Create();
await using var fs = new FileStream(fileName, FileMode.Open);
fs.Position = 0;
return await md5.ComputeHashAsync(fs);
// ReSharper disable once UseAwaitUsing
// ReSharper disable once ConvertToUsingDeclaration
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
fs.Position = 0;
return await md5.ComputeHashAsync(fs);
}
}
public async Task<Either<BaseError, string>> CopyArtworkToCache(string path, ArtworkKind artworkKind)

Loading…
Cancel
Save