From b077b19e04a8da7b5017de20664f107554ab17f0 Mon Sep 17 00:00:00 2001 From: Adam Carter Date: Wed, 16 Sep 2020 17:47:42 -0700 Subject: [PATCH] re-arranged the FC constructor so that cleaning check occurs after CacheManager construction (prevents runtime exception, addresses #42) --- src/FileCache/FileCache.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/FileCache/FileCache.cs b/src/FileCache/FileCache.cs index 6d89f82..84464a9 100644 --- a/src/FileCache/FileCache.cs +++ b/src/FileCache/FileCache.cs @@ -341,6 +341,14 @@ private void Init( _cleanInterval = cleanInterval; } + //set up cache manager + CacheManager = FileCacheManagerFactory.Create(manager); + CacheManager.CacheDir = CacheDir; + CacheManager.CacheSubFolder = _cacheSubFolder; + CacheManager.PolicySubFolder = _policySubFolder; + CacheManager.Binder = _binder; + CacheManager.AccessTimeout = new TimeSpan(); + //check to see if cache is in need of immediate cleaning if (ShouldClean()) { @@ -353,14 +361,6 @@ private void Init( UpdateCacheSizeAsync(); } - //set up cache manager - CacheManager = FileCacheManagerFactory.Create(manager); - CacheManager.CacheDir = CacheDir; - CacheManager.CacheSubFolder = _cacheSubFolder; - CacheManager.PolicySubFolder = _policySubFolder; - CacheManager.Binder = _binder; - CacheManager.AccessTimeout = new TimeSpan(); - MaxCacheSizeReached += FileCache_MaxCacheSizeReached; }