Skip to content

Commit

Permalink
com.utilities.rest 2.2.5 (#50)
Browse files Browse the repository at this point in the history
- fixed cache write
  • Loading branch information
StephenHodgson authored Nov 2, 2023
1 parent 84d6a70 commit 9fce436
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
17 changes: 2 additions & 15 deletions Runtime/DiskDownloadCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,16 @@ public void DeleteDownloadCache()
/// <inheritdoc />
public async Task WriteCacheItemAsync(byte[] data, string cachePath, CancellationToken cancellationToken)
{
if (File.Exists(cachePath))
{
return;
}

FileStream fileStream = null;
if (File.Exists(cachePath)) { return; }

try
{
fileStream = new FileStream(cachePath, FileMode.CreateNew, FileAccess.Read);
await fileStream.WriteAsync(data, 0, data.Length, cancellationToken).ConfigureAwait(true);
await File.WriteAllBytesAsync(cachePath, data, cancellationToken);
}
catch (Exception e)
{
Debug.LogError($"Failed to write asset to disk! {e}");
}
finally
{
if (fileStream != null)
{
await fileStream.DisposeAsync().ConfigureAwait(true);
}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Utilities.Rest",
"description": "This package contains useful RESTful utilities for the Unity Game Engine.",
"keywords": [],
"version": "2.2.4",
"version": "2.2.5",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest/releases",
Expand Down

0 comments on commit 9fce436

Please sign in to comment.