diff --git a/rhodecode/apps/_base/__init__.py b/rhodecode/apps/_base/__init__.py --- a/rhodecode/apps/_base/__init__.py +++ b/rhodecode/apps/_base/__init__.py @@ -305,6 +305,11 @@ class RepoAppView(BaseAppView): settings = settings_model.get_general_settings() return settings.get(settings_key, default) + def _get_repo_setting(self, target_repo, settings_key, default=False): + settings_model = VcsSettingsModel(repo=target_repo) + settings = settings_model.get_repo_settings_inherited() + return settings.get(settings_key, default) + def get_recache_flag(self): for flag_name in ['force_recache', 'force-recache', 'no-cache']: flag_val = self.request.GET.get(flag_name) diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -305,6 +305,21 @@ class RepoFilesView(RepoAppView): pure_path = pathlib2.PurePath(*sanitized_path) return pure_path + def _is_lf_enabled(self, target_repo): + lf_enabled = False + + lf_key_for_vcs_map = { + 'hg': 'extensions_largefiles', + 'git': 'vcs_git_lfs_enabled' + } + + lf_key_for_vcs = lf_key_for_vcs_map.get(target_repo.repo_type) + + if lf_key_for_vcs: + lf_enabled = self._get_repo_setting(target_repo, lf_key_for_vcs) + + return lf_enabled + @LoginRequired() @HasRepoPermissionAnyDecorator( 'repository.read', 'repository.write', 'repository.admin') @@ -645,7 +660,11 @@ class RepoFilesView(RepoAppView): # load file content if c.file.is_file(): - c.lf_node = c.file.get_largefile_node() + c.lf_node = {} + + has_lf_enabled = self._is_lf_enabled(self.db_repo) + if has_lf_enabled: + c.lf_node = c.file.get_largefile_node() c.file_source_page = 'true' c.file_last_commit = c.file.last_commit diff --git a/rhodecode/lib/vcs/backends/hg/commit.py b/rhodecode/lib/vcs/backends/hg/commit.py --- a/rhodecode/lib/vcs/backends/hg/commit.py +++ b/rhodecode/lib/vcs/backends/hg/commit.py @@ -330,8 +330,8 @@ class MercurialCommit(base.BaseCommit): return self.nodes[path] def get_largefile_node(self, path): - - if self._remote.is_large_file(path): + pointer_spec = self._remote.is_large_file(path) + if pointer_spec: # content of that file regular FileNode is the hash of largefile file_id = self.get_file_content(path).strip() diff --git a/rhodecode/model/settings.py b/rhodecode/model/settings.py --- a/rhodecode/model/settings.py +++ b/rhodecode/model/settings.py @@ -521,6 +521,12 @@ class VcsSettingsModel(object): return self._collect_all_settings(global_=False) @assert_repo_settings + def get_repo_settings_inherited(self): + global_settings = self.get_global_settings() + global_settings.update(self.get_repo_settings()) + return global_settings + + @assert_repo_settings def create_or_update_repo_settings( self, data, inherit_global_settings=False): from rhodecode.model.scm import ScmModel