1. Radomir Dopieralski
  2. hatta
  3. Issues
Issue #111 closed

cache update does not work because all_pages() returns empty list of pages

pinky
created an issue

all_pages() returns empty list of pages (and thus cache refresh does not work)

config: pages_path = repo/pages/ repo_path = repo/ cache_path = cache/

the problem si caused by line in all_pages()

'/' not in repo_file[len(self.repo_prefix)

This only happens when 'pages_path' is set to some subdirectory in repository (with defalt config works fine)

Comments (9)

  1. Vlad Glagolev

    The issue is that repo_file[len(self.repo_prefix):] gives us "/Home", "/Test" instead of "Home", "Test" with the config like that:

        config = hatta.WikiConfig(
        pages_path = 'repo/pages',
        repo_path = 'repo',
        cache_path = 'cache')
    

    and it doesn't with this one:

        config = hatta.WikiConfig(
        pages_path = 'repo',
        repo_path = 'repo',
        cache_path = 'cache')
    

    so, e.g. repo_file becomes "pages/Home" and repo_prefix becomes "pages".

    but the question is: what is the '/' not in repo_file[len(self.repo_prefix):] check for?

    as it is the only difference for all_pages() in WikiSubdirectoryStorage:

        def all_pages(self):
            """Iterate over the titles of all pages in the wiki."""
    
            for repo_file in self._changectx():
                if repo_file.startswith(self.repo_prefix):
                    title = self._file_to_title(repo_file)
                    if title in self:
                        yield title
    

    that line is also the reason we have history entries displayed with no issue (via history()):

                    if repo_file.startswith(self.repo_prefix):
                        title = self._file_to_title(repo_file)
    
  2. Vlad Glagolev

    As discussed on IRC, the line is needed to check for subdirectories:

    [10:28'23] deshipu> yeah, that check is needed there so that it doesn't pick up subdirectories when
    

    We decided to normalize paths like that, so e.g. /a/b/c would become a/b/c.

    The proposed patch is as follows:

    --- a/hatta/storage.py  Tue Sep 08 17:01:44 2015 +0300
    +++ b/hatta/storage.py  Wed Sep 30 11:40:39 2015 +0300
    @@ -402,7 +402,7 @@
    
             for repo_file in self._changectx():
                 if (repo_file.startswith(self.repo_prefix) and
    -                '/' not in repo_file[len(self.repo_prefix):]):
    +                '/' not in repo_file[len(self.repo_prefix):].strip('/')):
                     title = self._file_to_title(repo_file)
                     if title in self:
                         yield title
    
  3. Log in to comment