diff options
Diffstat (limited to 'BackEnd/Timeline/Services')
-rw-r--r-- | BackEnd/Timeline/Services/Data/DataManager.cs | 93 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Data/DataManagerExtensions.cs | 26 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Data/ETagGenerator.cs | 16 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Data/IDataManager.cs | 49 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Data/IETagGenerator.cs | 19 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Data/Resource.Designer.cs | 117 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Data/Resource.resx | 138 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/User/UserAvatarService.cs | 2 |
8 files changed, 382 insertions, 78 deletions
diff --git a/BackEnd/Timeline/Services/Data/DataManager.cs b/BackEnd/Timeline/Services/Data/DataManager.cs index d9a4491d..9de17da3 100644 --- a/BackEnd/Timeline/Services/Data/DataManager.cs +++ b/BackEnd/Timeline/Services/Data/DataManager.cs @@ -1,73 +1,40 @@ using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
using System;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Timeline.Entities;
namespace Timeline.Services.Data
{
- /// <summary>
- /// A data manager controlling data.
- /// </summary>
- /// <remarks>
- /// Identical data will be saved as one copy and return the same tag.
- /// Every data has a ref count. When data is retained, ref count increase.
- /// When data is freed, ref count decease. If ref count is decreased
- /// to 0, the data entry will be destroyed and no longer occupy space.
- /// </remarks>
- public interface IDataManager
- {
- /// <summary>
- /// Saves the data to a new entry if it does not exist,
- /// increases its ref count and returns a tag to the entry.
- /// </summary>
- /// <param name="data">The data. Can't be null.</param>
- /// <returns>The tag of the created entry.</returns>
- /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/> is null.</exception>
- public Task<string> RetainEntry(byte[] data);
-
- /// <summary>
- /// Decrease the the ref count of the entry.
- /// Remove it if ref count is zero.
- /// </summary>
- /// <param name="tag">The tag of the entry.</param>
- /// <exception cref="ArgumentNullException">Thrown when <paramref name="tag"/> is null.</exception>
- /// <remarks>
- /// It's no-op if entry with tag does not exist.
- /// </remarks>
- public Task FreeEntry(string tag);
-
- /// <summary>
- /// Retrieve the entry with given tag. If not exist, returns null.
- /// </summary>
- /// <param name="tag">The tag of the entry.</param>
- /// <returns>The data of the entry. If not exist, returns null.</returns>
- /// <exception cref="ArgumentNullException">Thrown when <paramref name="tag"/> is null.</exception>
- public Task<byte[]?> GetEntry(string tag);
- }
-
public class DataManager : IDataManager
{
+ private readonly ILogger<DataManager> _logger;
private readonly DatabaseContext _database;
private readonly IETagGenerator _eTagGenerator;
- public DataManager(DatabaseContext database, IETagGenerator eTagGenerator)
+ public DataManager(ILogger<DataManager> logger, DatabaseContext database, IETagGenerator eTagGenerator)
{
+ _logger = logger;
_database = database;
_eTagGenerator = eTagGenerator;
}
- public async Task<string> RetainEntry(byte[] data)
+ public async Task<string> RetainEntry(byte[] data, CancellationToken cancellationToken = default)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
- var tag = await _eTagGenerator.Generate(data);
+ var tag = await _eTagGenerator.GenerateETagAsync(data, cancellationToken);
+
+ var entity = await _database.Data.Where(d => d.Tag == tag).SingleOrDefaultAsync(cancellationToken);
+ bool create;
- var entity = await _database.Data.Where(d => d.Tag == tag).SingleOrDefaultAsync();
if (entity == null)
{
+ create = true;
entity = new DataEntity
{
Tag = tag,
@@ -78,42 +45,54 @@ namespace Timeline.Services.Data }
else
{
+ create = false;
entity.Ref += 1;
}
- await _database.SaveChangesAsync();
+ await _database.SaveChangesAsync(cancellationToken);
+
+ _logger.LogInformation(create ? Resource.LogDataManagerRetainEntryCreate : Resource.LogDataManagerRetainEntryAddRefCount, tag);
return tag;
}
- public async Task FreeEntry(string tag)
+ public async Task FreeEntry(string tag, CancellationToken cancellationToken = default)
{
if (tag == null)
throw new ArgumentNullException(nameof(tag));
- var entity = await _database.Data.Where(d => d.Tag == tag).SingleOrDefaultAsync();
+ var entity = await _database.Data.Where(d => d.Tag == tag).SingleOrDefaultAsync(cancellationToken);
if (entity != null)
{
+ bool remove;
+
if (entity.Ref == 1)
{
+ remove = true;
_database.Data.Remove(entity);
}
else
{
+ remove = false;
entity.Ref -= 1;
}
- await _database.SaveChangesAsync();
+ await _database.SaveChangesAsync(cancellationToken);
+ _logger.LogInformation(remove ? Resource.LogDataManagerFreeEntryRemove : Resource.LogDataManagerFreeEntryDecreaseRefCount, tag);
+ }
+ else
+ {
+ _logger.LogInformation(Resource.LogDataManagerFreeEntryNotExist, tag);
}
}
- public async Task<byte[]?> GetEntry(string tag)
+ public async Task<byte[]?> GetEntry(string tag, CancellationToken cancellationToken = default)
{
if (tag == null)
throw new ArgumentNullException(nameof(tag));
- var entity = await _database.Data.Where(d => d.Tag == tag).Select(d => new { d.Data }).SingleOrDefaultAsync();
+ var entity = await _database.Data.Where(d => d.Tag == tag).Select(d => new { d.Data }).SingleOrDefaultAsync(cancellationToken);
if (entity is null)
return null;
@@ -121,18 +100,4 @@ namespace Timeline.Services.Data return entity.Data;
}
}
-
- public static class DataManagerExtensions
- {
- /// <summary>
- /// Try to get an entry and throw <see cref="DatabaseCorruptedException"/> if not exist.
- /// </summary>
- public static async Task<byte[]> GetEntryAndCheck(this IDataManager dataManager, string tag, string notExistMessage)
- {
- var data = await dataManager.GetEntry(tag);
- if (data is null)
- throw new DatabaseCorruptedException($"Can't get data of tag {tag}. {notExistMessage}");
- return data;
- }
- }
}
diff --git a/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs b/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs new file mode 100644 index 00000000..64d35b9b --- /dev/null +++ b/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs @@ -0,0 +1,26 @@ +using System;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.Data
+{
+ public static class DataManagerExtensions
+ {
+ /// <summary>
+ /// Try to get an entry and throw <see cref="DatabaseCorruptedException"/> if not exist.
+ /// </summary>
+ public static async Task<byte[]> GetEntryAndCheck(this IDataManager dataManager, string tag, string notExistMessage)
+ {
+ if (dataManager is null)
+ throw new ArgumentNullException(nameof(dataManager));
+ if (tag is null)
+ throw new ArgumentNullException(nameof(tag));
+ if (notExistMessage is null)
+ throw new ArgumentNullException(nameof(notExistMessage));
+
+ var data = await dataManager.GetEntry(tag);
+ if (data is null)
+ throw new DatabaseCorruptedException(string.Format(Resource.GetEntryAndCheckNotExist, tag, notExistMessage));
+ return data;
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Services/Data/ETagGenerator.cs b/BackEnd/Timeline/Services/Data/ETagGenerator.cs index 847c120b..03837dc9 100644 --- a/BackEnd/Timeline/Services/Data/ETagGenerator.cs +++ b/BackEnd/Timeline/Services/Data/ETagGenerator.cs @@ -1,20 +1,10 @@ using System;
using System.Security.Cryptography;
+using System.Threading;
using System.Threading.Tasks;
namespace Timeline.Services.Data
{
- public interface IETagGenerator
- {
- /// <summary>
- /// Generate a etag for given source.
- /// </summary>
- /// <param name="source">The source data.</param>
- /// <returns>The generated etag.</returns>
- /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is null.</exception>
- Task<string> Generate(byte[] source);
- }
-
public sealed class ETagGenerator : IETagGenerator, IDisposable
{
private readonly SHA1 _sha1;
@@ -25,12 +15,12 @@ namespace Timeline.Services.Data _sha1 = SHA1.Create();
}
- public Task<string> Generate(byte[] source)
+ public Task<string> GenerateETagAsync(byte[] source, CancellationToken cancellationToken = default)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
- return Task.Run(() => Convert.ToBase64String(_sha1.ComputeHash(source)));
+ return Task.Run(() => Convert.ToBase64String(_sha1.ComputeHash(source)), cancellationToken);
}
private bool _disposed; // To detect redundant calls
diff --git a/BackEnd/Timeline/Services/Data/IDataManager.cs b/BackEnd/Timeline/Services/Data/IDataManager.cs new file mode 100644 index 00000000..6a87c1b2 --- /dev/null +++ b/BackEnd/Timeline/Services/Data/IDataManager.cs @@ -0,0 +1,49 @@ +using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.Data
+{
+ /// <summary>
+ /// A data manager controlling data.
+ /// </summary>
+ /// <remarks>
+ /// Identical data will be saved as one copy and return the same tag.
+ /// Every data has a ref count. When data is retained, ref count increase.
+ /// When data is freed, ref count decease. If ref count is decreased
+ /// to 0, the data entry will be destroyed and no longer occupy space.
+ /// </remarks>
+ public interface IDataManager
+ {
+ /// <summary>
+ /// Saves the data to a new entry if it does not exist,
+ /// increases its ref count and returns a tag to the entry.
+ /// </summary>
+ /// <param name="data">The data. Can't be null.</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <returns>The tag of the created entry.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/> is null.</exception>
+ public Task<string> RetainEntry(byte[] data, CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Decrease the the ref count of the entry.
+ /// Remove it if ref count is zero.
+ /// </summary>
+ /// <param name="tag">The tag of the entry.</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="tag"/> is null.</exception>
+ /// <remarks>
+ /// It's no-op if entry with tag does not exist.
+ /// </remarks>
+ public Task FreeEntry(string tag, CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Retrieve the entry with given tag. If not exist, returns null.
+ /// </summary>
+ /// <param name="tag">The tag of the entry.</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <returns>The data of the entry. If not exist, returns null.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="tag"/> is null.</exception>
+ public Task<byte[]?> GetEntry(string tag, CancellationToken cancellationToken = default);
+ }
+}
diff --git a/BackEnd/Timeline/Services/Data/IETagGenerator.cs b/BackEnd/Timeline/Services/Data/IETagGenerator.cs new file mode 100644 index 00000000..fa81c449 --- /dev/null +++ b/BackEnd/Timeline/Services/Data/IETagGenerator.cs @@ -0,0 +1,19 @@ +using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.Data
+{
+ public interface IETagGenerator
+ {
+ /// <summary>
+ /// Generate a etag for given source.
+ /// </summary>
+ /// <param name="source">The source data.</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <returns>The generated etag.</returns>
+ /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is null.</exception>
+ /// <remarks>This function must guarantee the same result with equal given source.</remarks>
+ Task<string> GenerateETagAsync(byte[] source, CancellationToken cancellationToken = default);
+ }
+}
diff --git a/BackEnd/Timeline/Services/Data/Resource.Designer.cs b/BackEnd/Timeline/Services/Data/Resource.Designer.cs new file mode 100644 index 00000000..46b9eaf0 --- /dev/null +++ b/BackEnd/Timeline/Services/Data/Resource.Designer.cs @@ -0,0 +1,117 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Timeline.Services.Data {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Services.Data.Resource", typeof(Resource).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Can't get data entry of tag {0}. {1}.
+ /// </summary>
+ internal static string GetEntryAndCheckNotExist {
+ get {
+ return ResourceManager.GetString("GetEntryAndCheckNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Decrease ref count of existing entry with tag {0}..
+ /// </summary>
+ internal static string LogDataManagerFreeEntryDecreaseRefCount {
+ get {
+ return ResourceManager.GetString("LogDataManagerFreeEntryDecreaseRefCount", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Attempt to free an entry that does not exist with tag {0}..
+ /// </summary>
+ internal static string LogDataManagerFreeEntryNotExist {
+ get {
+ return ResourceManager.GetString("LogDataManagerFreeEntryNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Remove a entry with tag {0}..
+ /// </summary>
+ internal static string LogDataManagerFreeEntryRemove {
+ get {
+ return ResourceManager.GetString("LogDataManagerFreeEntryRemove", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Add ref count of existing entry with tag {0}..
+ /// </summary>
+ internal static string LogDataManagerRetainEntryAddRefCount {
+ get {
+ return ResourceManager.GetString("LogDataManagerRetainEntryAddRefCount", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Create a new entry with tag {0}..
+ /// </summary>
+ internal static string LogDataManagerRetainEntryCreate {
+ get {
+ return ResourceManager.GetString("LogDataManagerRetainEntryCreate", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Services/Data/Resource.resx b/BackEnd/Timeline/Services/Data/Resource.resx new file mode 100644 index 00000000..6783efae --- /dev/null +++ b/BackEnd/Timeline/Services/Data/Resource.resx @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="GetEntryAndCheckNotExist" xml:space="preserve">
+ <value>Can't get data entry of tag {0}. {1}</value>
+ </data>
+ <data name="LogDataManagerFreeEntryDecreaseRefCount" xml:space="preserve">
+ <value>Decrease ref count of existing entry with tag {0}.</value>
+ </data>
+ <data name="LogDataManagerFreeEntryNotExist" xml:space="preserve">
+ <value>Attempt to free an entry that does not exist with tag {0}.</value>
+ </data>
+ <data name="LogDataManagerFreeEntryRemove" xml:space="preserve">
+ <value>Remove a entry with tag {0}.</value>
+ </data>
+ <data name="LogDataManagerRetainEntryAddRefCount" xml:space="preserve">
+ <value>Add ref count of existing entry with tag {0}.</value>
+ </data>
+ <data name="LogDataManagerRetainEntryCreate" xml:space="preserve">
+ <value>Create a new entry with tag {0}.</value>
+ </data>
+</root>
\ No newline at end of file diff --git a/BackEnd/Timeline/Services/User/UserAvatarService.cs b/BackEnd/Timeline/Services/User/UserAvatarService.cs index 0a4b7438..a92df3cb 100644 --- a/BackEnd/Timeline/Services/User/UserAvatarService.cs +++ b/BackEnd/Timeline/Services/User/UserAvatarService.cs @@ -95,7 +95,7 @@ namespace Timeline.Services.User if (_cacheData == null || File.GetLastWriteTime(path) > _cacheDigest!.LastModified)
{
var data = await File.ReadAllBytesAsync(path);
- _cacheDigest = new CacheableDataDigest(await _eTagGenerator.Generate(data), File.GetLastWriteTime(path));
+ _cacheDigest = new CacheableDataDigest(await _eTagGenerator.GenerateETagAsync(data), File.GetLastWriteTime(path));
Image.Identify(data, out var format);
_cacheData = new ByteData(data, format.DefaultMimeType);
}
|