Skip to content

Commit

Permalink
🐛 Fix image uploading bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hexawyz committed Feb 8, 2025
1 parent c5343d2 commit 53924f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Exo/Service/Exo.Service.Core/ImageStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,17 @@ public async ValueTask AddImageAsync(string imageName, ReadOnlyMemory<byte> data
string fileName = GetFileName(_imageCacheDirectory, metadata.Id);
if (File.Exists(fileName)) throw new InvalidOperationException("An image with the same data already exists.");

await _imagesConfigurationContainer.WriteValueAsync(imageName, metadata, cancellationToken).ConfigureAwait(false);
await _imagesConfigurationContainer.WriteValueAsync
(
imageName,
new ImageMetadata(metadata.Id, metadata.Width, metadata.Height, metadata.Format, metadata.IsAnimated),
cancellationToken
).ConfigureAwait(false);

await File.WriteAllBytesAsync(fileName, data, cancellationToken).ConfigureAwait(false);

_imageCollection.Add(imageName, metadata);
if (!_imageCollectionById.TryAdd(metadata.Id, metadata)) throw new UnreachableException();

if (Volatile.Read(ref _changeListeners) is { } changeListeners)
{
Expand Down

0 comments on commit 53924f1

Please sign in to comment.