Skip to content

Commit

Permalink
Cache subproject path
Browse files Browse the repository at this point in the history
This becomes expensive when using weblate:// links.
  • Loading branch information
nijel committed Jul 18, 2013
1 parent 9b04057 commit 19f4022
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions trans/models/subproject.py
Expand Up @@ -236,6 +236,7 @@ def __init__(self, *args, **kwargs):
self._file_format = None
self._template_store = None
self._percents = None
self._dir_path = None

def has_acl(self, user):
'''
Expand Down Expand Up @@ -288,11 +289,17 @@ def get_full_slug(self):
def get_path(self):
'''
Returns full path to subproject git repository.
Caching is really necessary for linked project, otherwise
we end up fetching linked subproject again and again.
'''
if self.is_repo_link():
return self.linked_subproject.get_path()
if self._dir_path is None:
if self.is_repo_link():
self._dir_path = self.linked_subproject.get_path()
else:
self._dir_path = os.path.join(self.project.get_path(), self.slug)

return os.path.join(self.project.get_path(), self.slug)
return self._dir_path

def get_git_lock_path(self):
'''
Expand Down

0 comments on commit 19f4022

Please sign in to comment.