diff --git a/src/Core/Services/CipherService.cs b/src/Core/Services/CipherService.cs index f2860600a..aa3aa4522 100644 --- a/src/Core/Services/CipherService.cs +++ b/src/Core/Services/CipherService.cs @@ -576,10 +576,10 @@ namespace Bit.Core.Services var attachmentTasks = new List(); Cipher cipher = null; //If the cipher doesn't have a key, we update it - if(cipherView.Key == null) + if(await ShouldUseCipherKeyEncryptionAsync() && cipherView.Key == null) { cipher = await EncryptAsync(cipherView); - await UpdateAndUpsertAsync(async () => await _apiService.PutCipherAsync(cipherView.Id, new CipherRequest(cipher))); + await UpdateAndUpsertAsync(() => _apiService.PutCipherAsync(cipherView.Id, new CipherRequest(cipher))); cipher = await GetAsync(cipherView.Id); cipherView = await cipher.DecryptAsync(); } @@ -597,7 +597,7 @@ namespace Bit.Core.Services cipherView.OrganizationId = organizationId; cipherView.CollectionIds = collectionIds; cipher = await EncryptAsync(cipherView); - await UpdateAndUpsertAsync(async () => await _apiService.PutShareCipherAsync(cipherView.Id, new CipherShareRequest(cipher)), collectionIds); + await UpdateAndUpsertAsync(() => _apiService.PutShareCipherAsync(cipherView.Id, new CipherShareRequest(cipher)), collectionIds); } public async Task SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data) @@ -1360,9 +1360,9 @@ namespace Bit.Core.Services } } - private async Task UpdateAndUpsertAsync(Func> func, HashSet collectionIds = null) + private async Task UpdateAndUpsertAsync(Func> callPutCipherApi, HashSet collectionIds = null) { - var response = await func(); + var response = await callPutCipherApi(); var data = new CipherData(response, await _stateService.GetActiveUserIdAsync(), collectionIds); await UpsertAsync(data); }