internal async Task <List <string> > AddParentCacheIfNotExistAsync(IEnumerable <string> updatedPaths) { var parentDirectoryList = new HashSet <string>(); foreach (var path in updatedPaths) { parentDirectoryList.Add(FilenamesHelper.GetParentPath(path)); } var shouldAddParentDirectoriesToCache = parentDirectoryList.Where(parentDirectory => !_query.CacheGetParentFolder(parentDirectory).Item1).ToList(); if (!shouldAddParentDirectoriesToCache.Any()) { return(new List <string>()); } var databaseQueryResult = await _query.GetAllObjectsAsync(shouldAddParentDirectoriesToCache); _logger.LogInformation("[AddParentCacheIfNotExist] files added to cache " + string.Join(",", shouldAddParentDirectoriesToCache)); foreach (var directory in shouldAddParentDirectoriesToCache) { var byDirectory = databaseQueryResult.Where(p => p.ParentDirectory == directory).ToList(); _query.AddCacheParentItem(directory, byDirectory); } return(shouldAddParentDirectoriesToCache); }
public void ListCache_GetCache() { // Act var controller = new CacheIndexController(_query, _appSettings); controller.ControllerContext.HttpContext = new DefaultHttpContext(); _query.AddCacheParentItem("/list-cache", new List <FileIndexItem> { new FileIndexItem { FileName = "cacheDeleteTest2", ParentDirectory = "/list-cache", IsDirectory = true } }); // Act, remove content from cache var actionResult = controller.ListCache("/list-cache") as JsonResult; Assert.IsNotNull(actionResult); Assert.IsNotNull(actionResult.Value); }