Esempio n. 1
0
        public async void MovePage(string oldWikiPath, string newWikiPath, string oldWikiUrl, string newWikiUrl)
        {
            System.IO.File.Move(oldWikiPath, newWikiPath);

            string contents;

            if (pageCache.TryGetContents(oldWikiUrl, out contents))
            {
                pageCache.DeleteFromCache(oldWikiUrl);
                pageCache.CachePageContents(newWikiUrl, contents);
            }
            else
            {
                var result = await fileReader.TryReadFile(newWikiPath);

                if (result.Item1)
                {
                    ConvertAndWritePage(newWikiPath, newWikiUrl, result.Item2);
                }
            }

            FireEvent(PageMoved, newWikiPath, oldWikiPath);
        }
Esempio n. 2
0
        private async Task <Tuple <bool, string> > TryGetPageContents(string siteName, ImmutableWikiPage page)
        {
            IPageCache pageCache = null;
            string     content   = null;

            // TODO: Async-ify
            bool hasCache           = config.TryGetPageCache(siteName, out pageCache);
            bool pageContentsCached = hasCache && pageCache.TryGetContents(page.WikiUrl, out content);

            Tuple <bool, string> results = new Tuple <bool, string>(false, string.Empty);

            if (!pageContentsCached)
            {
                results = await fileReader.TryReadFile(page.WikiPath);
            }

            // cache the contents if they weren't already
            if (hasCache && !pageContentsCached && results.Item1)
            {
                pageCache.CachePageContents(page.WikiUrl, results.Item2);
            }

            return(results);
        }