diff options
Diffstat (limited to 'BackEnd')
16 files changed, 329 insertions, 35 deletions
diff --git a/BackEnd/Timeline/Services/Data/DataManager.cs b/BackEnd/Timeline/Services/Data/DataManager.cs index 9de17da3..6cf3225f 100644 --- a/BackEnd/Timeline/Services/Data/DataManager.cs +++ b/BackEnd/Timeline/Services/Data/DataManager.cs @@ -21,7 +21,7 @@ namespace Timeline.Services.Data _eTagGenerator = eTagGenerator;
}
- public async Task<string> RetainEntry(byte[] data, CancellationToken cancellationToken = default)
+ public async Task<string> RetainEntryAsync(byte[] data, CancellationToken cancellationToken = default)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
@@ -56,7 +56,7 @@ namespace Timeline.Services.Data return tag;
}
- public async Task FreeEntry(string tag, CancellationToken cancellationToken = default)
+ public async Task FreeEntryAsync(string tag, CancellationToken cancellationToken = default)
{
if (tag == null)
throw new ArgumentNullException(nameof(tag));
@@ -87,7 +87,7 @@ namespace Timeline.Services.Data }
}
- public async Task<byte[]?> GetEntry(string tag, CancellationToken cancellationToken = default)
+ public async Task<byte[]?> GetEntryAsync(string tag, CancellationToken cancellationToken = default)
{
if (tag == null)
throw new ArgumentNullException(nameof(tag));
diff --git a/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs b/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs index 64d35b9b..d149f3fa 100644 --- a/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs +++ b/BackEnd/Timeline/Services/Data/DataManagerExtensions.cs @@ -1,4 +1,5 @@ using System;
+using System.Threading;
using System.Threading.Tasks;
namespace Timeline.Services.Data
@@ -8,7 +9,7 @@ namespace Timeline.Services.Data /// <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)
+ public static async Task<byte[]> GetEntryAndCheck(this IDataManager dataManager, string tag, string notExistMessage, CancellationToken cancellationToken = default)
{
if (dataManager is null)
throw new ArgumentNullException(nameof(dataManager));
@@ -17,7 +18,7 @@ namespace Timeline.Services.Data if (notExistMessage is null)
throw new ArgumentNullException(nameof(notExistMessage));
- var data = await dataManager.GetEntry(tag);
+ var data = await dataManager.GetEntryAsync(tag, cancellationToken);
if (data is null)
throw new DatabaseCorruptedException(string.Format(Resource.GetEntryAndCheckNotExist, tag, notExistMessage));
return data;
diff --git a/BackEnd/Timeline/Services/Data/DataServicesServiceCollectionExtensions.cs b/BackEnd/Timeline/Services/Data/DataServicesServiceCollectionExtensions.cs new file mode 100644 index 00000000..2717e63c --- /dev/null +++ b/BackEnd/Timeline/Services/Data/DataServicesServiceCollectionExtensions.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+
+namespace Timeline.Services.Data
+{
+ public static class DataServicesServiceCollectionExtensions
+ {
+ public static IServiceCollection AddDataServices(this IServiceCollection services)
+ {
+ services.TryAddScoped<IETagGenerator, ETagGenerator>();
+ services.TryAddScoped<IDataManager, DataManager>();
+ return services;
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Services/Data/IDataManager.cs b/BackEnd/Timeline/Services/Data/IDataManager.cs index 6a87c1b2..4191367e 100644 --- a/BackEnd/Timeline/Services/Data/IDataManager.cs +++ b/BackEnd/Timeline/Services/Data/IDataManager.cs @@ -23,7 +23,7 @@ namespace Timeline.Services.Data /// <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);
+ public Task<string> RetainEntryAsync(byte[] data, CancellationToken cancellationToken = default);
/// <summary>
/// Decrease the the ref count of the entry.
@@ -35,7 +35,7 @@ namespace Timeline.Services.Data /// <remarks>
/// It's no-op if entry with tag does not exist.
/// </remarks>
- public Task FreeEntry(string tag, CancellationToken cancellationToken = default);
+ public Task FreeEntryAsync(string tag, CancellationToken cancellationToken = default);
/// <summary>
/// Retrieve the entry with given tag. If not exist, returns null.
@@ -44,6 +44,6 @@ namespace Timeline.Services.Data /// <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);
+ public Task<byte[]?> GetEntryAsync(string tag, CancellationToken cancellationToken = default);
}
}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseBackupService.cs b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseBackupService.cs index c00b5f95..718edcb1 100644 --- a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseBackupService.cs +++ b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseBackupService.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
using System.Globalization;
using System.IO;
using System.Threading;
@@ -7,19 +8,16 @@ using Timeline.Entities; namespace Timeline.Services.DatabaseManagement
{
- public interface IDatabaseBackupService
- {
- Task BackupAsync(CancellationToken cancellationToken = default);
- }
-
public class DatabaseBackupService : IDatabaseBackupService
{
+ private readonly ILogger<DatabaseBackupService> _logger;
private readonly DatabaseContext _database;
private readonly IPathProvider _pathProvider;
private readonly IClock _clock;
- public DatabaseBackupService(DatabaseContext database, IPathProvider pathProvider, IClock clock)
+ public DatabaseBackupService(ILogger<DatabaseBackupService> logger, DatabaseContext database, IPathProvider pathProvider, IClock clock)
{
+ _logger = logger;
_database = database;
_pathProvider = pathProvider;
_clock = clock;
@@ -32,6 +30,7 @@ namespace Timeline.Services.DatabaseManagement var fileName = _clock.GetCurrentTime().ToString("yyyy-MM-ddTHH-mm-ss", CultureInfo.InvariantCulture);
var path = Path.Combine(backupDirPath, fileName);
await _database.Database.ExecuteSqlInterpolatedAsync($"VACUUM INTO {path}", cancellationToken);
+ _logger.LogWarning(Resource.DatabaseBackupServiceFinishBackup, path);
}
}
}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs index 2180ad40..20e2c074 100644 --- a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs +++ b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseCustomMigrator.cs @@ -7,17 +7,12 @@ using Timeline.Entities; namespace Timeline.Services.DatabaseManagement
{
- public interface IDatabaseCustomMigrator
- {
- Task MigrateAsync(CancellationToken cancellationToken = default);
- }
-
public class DatabaseCustomMigrator : IDatabaseCustomMigrator
{
- private IEnumerable<IDatabaseCustomMigration> _migrations;
- private DatabaseContext _database;
+ private readonly IEnumerable<IDatabaseCustomMigration> _migrations;
+ private readonly DatabaseContext _database;
- private ILogger<DatabaseCustomMigrator> _logger;
+ private readonly ILogger<DatabaseCustomMigrator> _logger;
public DatabaseCustomMigrator(IEnumerable<IDatabaseCustomMigration> migrations, DatabaseContext database, ILogger<DatabaseCustomMigrator> logger)
{
@@ -33,11 +28,11 @@ namespace Timeline.Services.DatabaseManagement var name = migration.GetName();
var isApplied = await _database.Migrations.AnyAsync(m => m.Name == name, cancellationToken);
- _logger.LogInformation("Found custom migration '{0}'. Applied: {1}.", name, isApplied);
+ _logger.LogInformation(Resource.DatabaseCustomMigratorFoundMigration, name, isApplied);
if (!isApplied)
{
- _logger.LogWarning("Begin custom migration '{0}'.", name);
+ _logger.LogWarning(Resource.DatabaseCustomMigratorBeginMigration, name);
await using var transaction = await _database.Database.BeginTransactionAsync(cancellationToken);
@@ -48,7 +43,7 @@ namespace Timeline.Services.DatabaseManagement await transaction.CommitAsync(cancellationToken);
- _logger.LogWarning("End custom migration '{0}'.", name);
+ _logger.LogWarning(Resource.DatabaseCustomMigratorFinishMigration, name);
}
}
}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseBackupService.cs b/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseBackupService.cs new file mode 100644 index 00000000..88f3d9b6 --- /dev/null +++ b/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseBackupService.cs @@ -0,0 +1,10 @@ +using System.Threading;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.DatabaseManagement
+{
+ public interface IDatabaseBackupService
+ {
+ Task BackupAsync(CancellationToken cancellationToken = default);
+ }
+}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigration.cs b/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigration.cs index 7300ccbd..a38dcb99 100644 --- a/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigration.cs +++ b/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigration.cs @@ -7,6 +7,15 @@ namespace Timeline.Services.DatabaseManagement public interface IDatabaseCustomMigration
{
string GetName();
+
+ /// <summary>
+ /// Execute the migration on database.
+ /// </summary>
+ /// <param name="database">The database.</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <remarks>
+ /// Do not create transaction since the migrator will take care of transaction.
+ /// </remarks>
Task ExecuteAsync(DatabaseContext database, CancellationToken cancellationToken = default);
}
}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigrator.cs b/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigrator.cs new file mode 100644 index 00000000..5eb43b92 --- /dev/null +++ b/BackEnd/Timeline/Services/DatabaseManagement/IDatabaseCustomMigrator.cs @@ -0,0 +1,10 @@ +using System.Threading;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.DatabaseManagement
+{
+ public interface IDatabaseCustomMigrator
+ {
+ Task MigrateAsync(CancellationToken cancellationToken = default);
+ }
+}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/MigationServiceCollectionExtensions.cs b/BackEnd/Timeline/Services/DatabaseManagement/MigationServiceCollectionExtensions.cs index d1f9b51c..8269ce28 100644 --- a/BackEnd/Timeline/Services/DatabaseManagement/MigationServiceCollectionExtensions.cs +++ b/BackEnd/Timeline/Services/DatabaseManagement/MigationServiceCollectionExtensions.cs @@ -1,14 +1,17 @@ using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Timeline.Services.DatabaseManagement
{
- public static class DatabaseManagementServiceCollectionExtensions
+ public static class DatabaseManagementServicesServiceCollectionExtensions
{
public static IServiceCollection AddDatabaseManagementService(this IServiceCollection services)
{
- services.AddScoped<IDatabaseCustomMigrator, DatabaseCustomMigrator>();
+ services.TryAddScoped<IDatabaseCustomMigrator, DatabaseCustomMigrator>();
services.AddScoped<IDatabaseCustomMigration, TimelinePostContentToDataMigration>();
- services.AddScoped<IDatabaseBackupService, DatabaseBackupService>();
+
+ services.TryAddScoped<IDatabaseBackupService, DatabaseBackupService>();
+
services.AddHostedService<DatabaseManagementService>();
return services;
}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/Resource.Designer.cs b/BackEnd/Timeline/Services/DatabaseManagement/Resource.Designer.cs new file mode 100644 index 00000000..c0e61a3f --- /dev/null +++ b/BackEnd/Timeline/Services/DatabaseManagement/Resource.Designer.cs @@ -0,0 +1,108 @@ +//------------------------------------------------------------------------------
+// <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.DatabaseManagement {
+ 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.DatabaseManagement.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 Database backup finished with output file at {0}..
+ /// </summary>
+ internal static string DatabaseBackupServiceFinishBackup {
+ get {
+ return ResourceManager.GetString("DatabaseBackupServiceFinishBackup", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Begin custom migration '{0}'..
+ /// </summary>
+ internal static string DatabaseCustomMigratorBeginMigration {
+ get {
+ return ResourceManager.GetString("DatabaseCustomMigratorBeginMigration", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to End custom migration '{0}'..
+ /// </summary>
+ internal static string DatabaseCustomMigratorFinishMigration {
+ get {
+ return ResourceManager.GetString("DatabaseCustomMigratorFinishMigration", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Found custom migration '{0}'. Applied: {1}..
+ /// </summary>
+ internal static string DatabaseCustomMigratorFoundMigration {
+ get {
+ return ResourceManager.GetString("DatabaseCustomMigratorFoundMigration", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Old image content does not have corresponding data with the tag..
+ /// </summary>
+ internal static string TimelinePostContentToDataMigrationImageNoData {
+ get {
+ return ResourceManager.GetString("TimelinePostContentToDataMigrationImageNoData", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/Resource.resx b/BackEnd/Timeline/Services/DatabaseManagement/Resource.resx new file mode 100644 index 00000000..9480ce64 --- /dev/null +++ b/BackEnd/Timeline/Services/DatabaseManagement/Resource.resx @@ -0,0 +1,135 @@ +<?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="DatabaseBackupServiceFinishBackup" xml:space="preserve">
+ <value>Database backup finished with output file at {0}.</value>
+ </data>
+ <data name="DatabaseCustomMigratorBeginMigration" xml:space="preserve">
+ <value>Begin custom migration '{0}'.</value>
+ </data>
+ <data name="DatabaseCustomMigratorFinishMigration" xml:space="preserve">
+ <value>End custom migration '{0}'.</value>
+ </data>
+ <data name="DatabaseCustomMigratorFoundMigration" xml:space="preserve">
+ <value>Found custom migration '{0}'. Applied: {1}.</value>
+ </data>
+ <data name="TimelinePostContentToDataMigrationImageNoData" xml:space="preserve">
+ <value>Old image content does not have corresponding data with the tag.</value>
+ </data>
+</root>
\ No newline at end of file diff --git a/BackEnd/Timeline/Services/DatabaseManagement/TimelinePostContentToDataMigration.cs b/BackEnd/Timeline/Services/DatabaseManagement/TimelinePostContentToDataMigration.cs index f9a3418b..f6662a97 100644 --- a/BackEnd/Timeline/Services/DatabaseManagement/TimelinePostContentToDataMigration.cs +++ b/BackEnd/Timeline/Services/DatabaseManagement/TimelinePostContentToDataMigration.cs @@ -35,7 +35,7 @@ namespace Timeline.Services.DatabaseManagement {
if (postEntity.ContentType == "text")
{
- var tag = await _dataManager.RetainEntry(Encoding.UTF8.GetBytes(postEntity.Content));
+ var tag = await _dataManager.RetainEntryAsync(Encoding.UTF8.GetBytes(postEntity.Content), cancellationToken);
database.TimelinePostData.Add(new TimelinePostDataEntity
{
DataTag = tag,
@@ -47,7 +47,7 @@ namespace Timeline.Services.DatabaseManagement }
else
{
- var data = await _dataManager.GetEntryAndCheck(postEntity.Content, "Old image content does not have corresponding data with the tag.");
+ var data = await _dataManager.GetEntryAndCheck(postEntity.Content, Resource.TimelinePostContentToDataMigrationImageNoData, cancellationToken);
var format = Image.DetectFormat(data);
database.TimelinePostData.Add(new TimelinePostDataEntity
{
diff --git a/BackEnd/Timeline/Services/Timeline/TimelinePostService.cs b/BackEnd/Timeline/Services/Timeline/TimelinePostService.cs index 073fffdf..6ca2e5a0 100644 --- a/BackEnd/Timeline/Services/Timeline/TimelinePostService.cs +++ b/BackEnd/Timeline/Services/Timeline/TimelinePostService.cs @@ -363,7 +363,7 @@ namespace Timeline.Services.Timeline {
var data = request.DataList[index];
- var tag = await _dataManager.RetainEntry(data.Data);
+ var tag = await _dataManager.RetainEntryAsync(data.Data);
_database.TimelinePostData.Add(new TimelinePostDataEntity
{
@@ -438,7 +438,7 @@ namespace Timeline.Services.Timeline foreach (var dataEntity in dataEntities)
{
- await _dataManager.FreeEntry(dataEntity.DataTag);
+ await _dataManager.FreeEntryAsync(dataEntity.DataTag);
}
_database.TimelinePostData.RemoveRange(dataEntities);
diff --git a/BackEnd/Timeline/Services/User/UserAvatarService.cs b/BackEnd/Timeline/Services/User/UserAvatarService.cs index a92df3cb..1b8896a6 100644 --- a/BackEnd/Timeline/Services/User/UserAvatarService.cs +++ b/BackEnd/Timeline/Services/User/UserAvatarService.cs @@ -200,7 +200,7 @@ namespace Timeline.Services.User await using var transaction = await _database.Database.BeginTransactionAsync();
- var tag = await _dataManager.RetainEntry(avatar.Data);
+ var tag = await _dataManager.RetainEntryAsync(avatar.Data);
var now = _clock.GetCurrentTime();
@@ -218,7 +218,7 @@ namespace Timeline.Services.User else
{
if (entity.DataTag is not null)
- await _dataManager.FreeEntry(entity.DataTag);
+ await _dataManager.FreeEntryAsync(entity.DataTag);
entity.DataTag = tag;
entity.Type = avatar.ContentType;
@@ -243,7 +243,7 @@ namespace Timeline.Services.User await using var transaction = await _database.Database.BeginTransactionAsync();
- await _dataManager.FreeEntry(entity.DataTag);
+ await _dataManager.FreeEntryAsync(entity.DataTag);
entity.DataTag = null;
entity.Type = null;
diff --git a/BackEnd/Timeline/Timeline.csproj b/BackEnd/Timeline/Timeline.csproj index 6a74d0c0..15771977 100644 --- a/BackEnd/Timeline/Timeline.csproj +++ b/BackEnd/Timeline/Timeline.csproj @@ -143,6 +143,11 @@ <AutoGen>True</AutoGen>
<DependentUpon>UserTokenService.resx</DependentUpon>
</Compile>
+ <Compile Update="Services\DatabaseManagement\Resource.Designer.cs">
+ <DesignTime>True</DesignTime>
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resource.resx</DependentUpon>
+ </Compile>
<Compile Update="Services\Data\Resource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
@@ -253,6 +258,10 @@ <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>UserTokenService.Designer.cs</LastGenOutput>
</EmbeddedResource>
+ <EmbeddedResource Update="Services\DatabaseManagement\Resource.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resource.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
<EmbeddedResource Update="Services\Data\Resource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
|