diff options
author | crupest <crupest@outlook.com> | 2020-03-06 18:12:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-06 18:12:51 +0800 |
commit | 81218733d494452e04a1ab84fae242d0bba08092 (patch) | |
tree | 4d320ffd64854cc959ebc7b763f2766505198b13 | |
parent | a88ce6495185e7e63c5c1362c7e3f8660b89333d (diff) | |
download | timeline-81218733d494452e04a1ab84fae242d0bba08092.tar.gz timeline-81218733d494452e04a1ab84fae242d0bba08092.tar.bz2 timeline-81218733d494452e04a1ab84fae242d0bba08092.zip |
...
-rw-r--r-- | Timeline/Services/DataManager.cs | 3 | ||||
-rw-r--r-- | Timeline/Services/UserAvatarService.cs | 4 | ||||
-rw-r--r-- | Timeline/Startup.cs | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/Timeline/Services/DataManager.cs b/Timeline/Services/DataManager.cs index d6b8b6a4..d447b0d5 100644 --- a/Timeline/Services/DataManager.cs +++ b/Timeline/Services/DataManager.cs @@ -76,13 +76,12 @@ namespace Timeline.Services Ref = 1
};
_database.Data.Add(entity);
- await _database.SaveChangesAsync();
}
else
{
entity.Ref += 1;
- await _database.SaveChangesAsync();
}
+ await _database.SaveChangesAsync();
return tag;
}
diff --git a/Timeline/Services/UserAvatarService.cs b/Timeline/Services/UserAvatarService.cs index 5a07da96..52d079a3 100644 --- a/Timeline/Services/UserAvatarService.cs +++ b/Timeline/Services/UserAvatarService.cs @@ -258,6 +258,7 @@ namespace Timeline.Services else
{
await _avatarValidator.Validate(avatar);
+ var tag = await _dataManager.RetainEntry(avatar.Data);
var oldTag = avatarEntity?.DataTag;
var create = avatarEntity == null;
if (avatarEntity == null)
@@ -265,7 +266,6 @@ namespace Timeline.Services avatarEntity = new UserAvatarEntity();
_database.UserAvatars.Add(avatarEntity);
}
- var tag = await _dataManager.RetainEntry(avatar.Data);
avatarEntity.DataTag = tag;
avatarEntity.Type = avatar.Type;
avatarEntity.LastModified = _clock.GetCurrentTime();
@@ -287,7 +287,7 @@ namespace Timeline.Services public static void AddUserAvatarService(this IServiceCollection services)
{
services.AddScoped<IUserAvatarService, UserAvatarService>();
- services.AddSingleton<IDefaultUserAvatarProvider, DefaultUserAvatarProvider>();
+ services.AddScoped<IDefaultUserAvatarProvider, DefaultUserAvatarProvider>();
services.AddTransient<IUserAvatarValidator, UserAvatarValidator>();
}
}
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index 14bd14cc..263e6b7a 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -93,6 +93,10 @@ namespace Timeline services.AddScoped<IUserService, UserService>();
services.AddScoped<IUserTokenService, JwtUserTokenService>();
services.AddScoped<IUserTokenManager, UserTokenManager>();
+
+ services.AddScoped<IETagGenerator, ETagGenerator>();
+ services.AddScoped<IDataManager, DataManager>();
+
services.AddUserAvatarService();
services.AddScoped<ITimelineService, TimelineService>();
|