Пример #1
0
        private CacheFolder GetMatchedCacheFolder(SystemFolder folderToFind, CacheFolder folderToLookIn)
        {
            if (folderToLookIn._childFolderNameToCacheFolder.TryGetValue(folderToFind.Name, out var cacheFolder) &&
                cacheFolder.Equals(folderToFind))
            {
                return(cacheFolder);
            }

            return(folderToLookIn._childFolderNameToCacheFolder.Values
                   .Select(childFolder => GetMatchedCacheFolder(folderToFind, childFolder))
                   .FirstOrDefault());
        }
Пример #2
0
        public override Task <IResult <Void> > CopyToAsync(SystemFolder destFolder)
        {
            var destCacheFolder = GetMatchedCacheFolder(destFolder, GetRootCacheFolder());

            if (destCacheFolder._childFolderNameToCacheFolder.ContainsKey(Name))
            {
                return(VoidSuccess());
            }

            Task.Run(async() =>
            {
                var copyToResult = await base.CopyToAsync(destFolder);

                if (copyToResult.IsSuccess)
                {
                    destCacheFolder._childFolderNameToCacheFolder.TryAdd(Name, this);
                    destCacheFolder.ClearPageCache();
                }
            });

            return(VoidFailure($"Could not copy folder with name {Name} to {destFolder.RelativePath}. Please try again..."));
        }