clear cache flag on disk

This commit is contained in:
Kyle Spearrin 2018-06-08 09:13:42 -04:00
parent b5277e89d5
commit a607a7f3ef
4 changed files with 28 additions and 1 deletions

View File

@ -17,5 +17,6 @@ namespace Bit.App.Abstractions
string ApiUrl { get; set; }
string IdentityUrl { get; set; }
string IconsUrl { get; set; }
bool ClearCiphersCache { get; set; }
}
}

View File

@ -46,6 +46,7 @@
public const string IdentityUrl = "other:identityUrl";
public const string IconsUrl = "other:iconsUrl";
public const string FailedPinAttempts = "other:failedPinAttempts";
public const string ClearCiphersCache = "other:clearCiphersCache";
public const int SelectFileRequestCode = 42;
public const int SelectFilePermissionRequestCode = 43;

View File

@ -196,5 +196,17 @@ namespace Bit.App.Services
_settings.AddOrUpdateValue(Constants.IconsUrl, value);
}
}
public bool ClearCiphersCache
{
get
{
return _settings.GetValueOrDefault(Constants.ClearCiphersCache, false);
}
set
{
_settings.AddOrUpdateValue(Constants.ClearCiphersCache, value);
}
}
}
}

View File

@ -25,6 +25,7 @@ namespace Bit.App.Services
private readonly ICipherApiRepository _cipherApiRepository;
private readonly ISettingsService _settingsService;
private readonly ICryptoService _cryptoService;
private readonly IAppSettingsService _appSettingsService;
public CipherService(
ICipherRepository cipherRepository,
@ -33,7 +34,8 @@ namespace Bit.App.Services
IAuthService authService,
ICipherApiRepository cipherApiRepository,
ISettingsService settingsService,
ICryptoService cryptoService)
ICryptoService cryptoService,
IAppSettingsService appSettingsService)
{
_cipherRepository = cipherRepository;
_cipherCollectionRepository = cipherCollectionRepository;
@ -42,6 +44,7 @@ namespace Bit.App.Services
_cipherApiRepository = cipherApiRepository;
_settingsService = settingsService;
_cryptoService = cryptoService;
_appSettingsService = appSettingsService;
}
public async Task<Cipher> GetByIdAsync(string id)
@ -59,6 +62,12 @@ namespace Bit.App.Services
public async Task<IEnumerable<Cipher>> GetAllAsync()
{
if(_appSettingsService.ClearCiphersCache)
{
CachedCiphers = null;
_appSettingsService.ClearCiphersCache = false;
}
if(CachedCiphers != null)
{
return CachedCiphers;
@ -261,6 +270,7 @@ namespace Bit.App.Services
{
await _cipherRepository.UpsertAsync(cipher);
CachedCiphers = null;
_appSettingsService.ClearCiphersCache = true;
}
public async Task<ApiResult> DeleteAsync(string id)
@ -283,6 +293,7 @@ namespace Bit.App.Services
{
await _cipherRepository.DeleteAsync(id);
CachedCiphers = null;
_appSettingsService.ClearCiphersCache = true;
}
public async Task<byte[]> DownloadAndDecryptAttachmentAsync(string url, string orgId = null)
@ -348,6 +359,7 @@ namespace Bit.App.Services
await _attachmentRepository.UpsertAsync(attachment);
}
CachedCiphers = null;
_appSettingsService.ClearCiphersCache = true;
}
public async Task<ApiResult> DeleteAttachmentAsync(Cipher cipher, string attachmentId)
@ -370,6 +382,7 @@ namespace Bit.App.Services
{
await _attachmentRepository.DeleteAsync(attachmentId);
CachedCiphers = null;
_appSettingsService.ClearCiphersCache = true;
}
private Tuple<string, string[]> InfoFromMobileAppUri(string mobileAppUriString)