aboutsummaryrefslogtreecommitdiff
path: root/BackEnd
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd')
-rw-r--r--BackEnd/Timeline/Services/DataManager.cs16
-rw-r--r--BackEnd/Timeline/Services/Migration/TimelinePostContentToDataMigration.cs2
-rw-r--r--BackEnd/Timeline/Services/TimelinePostService.cs4
3 files changed, 9 insertions, 13 deletions
diff --git a/BackEnd/Timeline/Services/DataManager.cs b/BackEnd/Timeline/Services/DataManager.cs
index b697630c..b43b80f9 100644
--- a/BackEnd/Timeline/Services/DataManager.cs
+++ b/BackEnd/Timeline/Services/DataManager.cs
@@ -22,22 +22,20 @@ namespace Timeline.Services
/// increases its ref count and returns a tag to the entry.
/// </summary>
/// <param name="data">The data. Can't be null.</param>
- /// <param name="saveDatabaseChange">If true save database change. Otherwise it does not save database change.</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, bool saveDatabaseChange = true);
+ 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>
- /// <param name="saveDatabaseChange">If true save database change. Otherwise it does not save database change.</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, bool saveDatabaseChange = true);
+ public Task FreeEntry(string tag);
/// <summary>
/// Retrieve the entry with given tag. If not exist, returns null.
@@ -59,7 +57,7 @@ namespace Timeline.Services
_eTagGenerator = eTagGenerator;
}
- public async Task<string> RetainEntry(byte[] data, bool saveDatabaseChange = true)
+ public async Task<string> RetainEntry(byte[] data)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
@@ -83,13 +81,12 @@ namespace Timeline.Services
entity.Ref += 1;
}
- if (saveDatabaseChange)
- await _database.SaveChangesAsync();
+ await _database.SaveChangesAsync();
return tag;
}
- public async Task FreeEntry(string tag, bool saveDatabaseChange)
+ public async Task FreeEntry(string tag)
{
if (tag == null)
throw new ArgumentNullException(nameof(tag));
@@ -107,8 +104,7 @@ namespace Timeline.Services
entity.Ref -= 1;
}
- if (saveDatabaseChange)
- await _database.SaveChangesAsync();
+ await _database.SaveChangesAsync();
}
}
diff --git a/BackEnd/Timeline/Services/Migration/TimelinePostContentToDataMigration.cs b/BackEnd/Timeline/Services/Migration/TimelinePostContentToDataMigration.cs
index de2e2183..bb7bf606 100644
--- a/BackEnd/Timeline/Services/Migration/TimelinePostContentToDataMigration.cs
+++ b/BackEnd/Timeline/Services/Migration/TimelinePostContentToDataMigration.cs
@@ -33,7 +33,7 @@ namespace Timeline.Services.Migration
{
if (postEntity.ContentType == "text")
{
- var tag = await _dataManager.RetainEntry(Encoding.UTF8.GetBytes(postEntity.Content), false);
+ var tag = await _dataManager.RetainEntry(Encoding.UTF8.GetBytes(postEntity.Content));
database.TimelinePostData.Add(new TimelinePostDataEntity
{
DataTag = tag,
diff --git a/BackEnd/Timeline/Services/TimelinePostService.cs b/BackEnd/Timeline/Services/TimelinePostService.cs
index 62bc43cc..88a93710 100644
--- a/BackEnd/Timeline/Services/TimelinePostService.cs
+++ b/BackEnd/Timeline/Services/TimelinePostService.cs
@@ -361,7 +361,7 @@ namespace Timeline.Services
{
var data = request.DataList[index];
- var tag = await _dataManager.RetainEntry(data.Data, false);
+ var tag = await _dataManager.RetainEntry(data.Data);
_database.TimelinePostData.Add(new TimelinePostDataEntity
{
@@ -436,7 +436,7 @@ namespace Timeline.Services
foreach (var dataEntity in dataEntities)
{
- await _dataManager.FreeEntry(dataEntity.DataTag, false);
+ await _dataManager.FreeEntry(dataEntity.DataTag);
}
_database.TimelinePostData.RemoveRange(dataEntities);