encryption: fix

This commit is contained in:
SuhorukovAnton 2020-09-03 14:48:36 +03:00
parent 15b17a0478
commit d8576a4b0a
5 changed files with 9 additions and 15 deletions

View File

@ -28,14 +28,12 @@ namespace ASC.Data.Storage.Encryption
private ICacheNotify<EncryptionSettingsProto> NotifySetting { get; }
private ICacheNotify<EncryptionStop> NotifyStop { get; }
private ICacheNotify<ProgressEncryption> ProgressEncryption { get; }
public EncryptionServiceClient(
ICacheNotify<EncryptionSettingsProto> notifySetting, ICacheNotify<ProgressEncryption> progressEncryption, ICacheNotify<EncryptionStop> notifyStop)
ICacheNotify<EncryptionSettingsProto> notifySetting, ICacheNotify<EncryptionStop> notifyStop)
{
NotifySetting = notifySetting;
NotifyStop = notifyStop;
ProgressEncryption = progressEncryption;
}
public void Start(EncryptionSettingsProto encryptionSettingsProto)
@ -48,12 +46,6 @@ namespace ASC.Data.Storage.Encryption
NotifyStop.Publish(new EncryptionStop(), CacheNotifyAction.Insert);
}
public void Get()
{
ProgressEncryption.Subscribe((n) => {
var k = n.Proggress;
},CacheNotifyAction.Insert);
}
}
public static class EncryptionServiceClientExtension

View File

@ -72,7 +72,7 @@ namespace ASC.Data.Storage.Encryption
{
if (!coreBaseSettings.Standalone)
{
//throw new NotSupportedException();
throw new NotSupportedException();
}
if (EncryptionSettings.Status == EncryprtionStatus.Encrypted || EncryptionSettings.Status == EncryprtionStatus.Decrypted)
@ -334,6 +334,7 @@ namespace ASC.Data.Storage.Encryption
private StorageFactoryConfig StorageFactoryConfig { get; set; }
private StorageFactory StorageFactory { get; set; }
private ICacheNotify<ProgressEncryption> ProgressEncryption { get; }
private IConfiguration Configuration { get; }
public EncryptionOperationScope(IOptionsMonitor<ILog> options,
StorageFactoryConfig storageFactoryConfig,
@ -342,6 +343,7 @@ namespace ASC.Data.Storage.Encryption
CoreBaseSettings coreBaseSettings,
NotifyHelper notifyHelper,
EncryptionSettingsHelper encryptionSettingsHelper,
IConfiguration configuration,
ICacheNotify<ProgressEncryption> progressEncryption)
{
Log = options.CurrentValue;
@ -352,6 +354,7 @@ namespace ASC.Data.Storage.Encryption
NotifyHelper = notifyHelper;
EncryptionSettingsHelper = encryptionSettingsHelper;
ProgressEncryption = progressEncryption;
Configuration = configuration;
}
public void Deconstruct( out ILog log, out EncryptionSettingsHelper encryptionSettingsHelper, out TenantManager tenantManager, out NotifyHelper notifyHelper, out CoreBaseSettings coreBaseSettings, out StorageFactoryConfig storageFactoryConfig, out StorageFactory storageFactory, out ICacheNotify<ProgressEncryption> progressEncryption, out IConfiguration configuration)
@ -372,7 +375,7 @@ namespace ASC.Data.Storage.Encryption
{
public static DIHelper AddEncryptionOperationService(this DIHelper services)
{
services.TryAddTransient<EncryptionOperation>();
services.TryAddSingleton<EncryptionOperation>();
services.TryAddScoped<EncryptionOperationScope>();
return services
.AddStorageFactoryConfigService()

View File

@ -51,7 +51,7 @@ namespace ASC.Data.Storage.Encryption
{
public static DIHelper AddEncryptionService(this DIHelper services)
{
services.TryAddTransient<EncryptionService>();
services.TryAddScoped<EncryptionService>();
return services.AddEncryptionWorkerService();
}
}

View File

@ -45,11 +45,11 @@ namespace ASC.Data.Storage.Encryption
public void Start(EncryptionSettingsProto encryptionSettings)
{
if (TokenSource.Token.IsCancellationRequested) return;
var encryptionOperation = FactoryOperation.CreateOperation(encryptionSettings);
EncryptionOperation encryptionOperation;
lock (Locker)
{
if (Cache.Get<EncryptionOperation>(GetCacheKey()) != null) return;
encryptionOperation = FactoryOperation.CreateOperation(encryptionSettings);
Cache.Insert(GetCacheKey(), encryptionOperation, DateTime.MaxValue);
}

View File

@ -1664,7 +1664,6 @@ namespace ASC.Api.Settings
Status = settings.Status
};
EncryptionServiceClient.Start(encryptionSettingsProto);
EncryptionServiceClient.Get();
}
[Read("encryptionStop")]