# HG changeset patch # User Milka Kuzminski # Date 2020-10-19 12:53:21 # Node ID 2e292c98334aa7e493fe6f1a56cf4b85a18261d8 # Parent d67d12ded9d69ee2d0be10f248f037a575354a49 archives: optimize performance of repo archive option by delegating all logic to vcsserver. - sending GBs of data over the wire was slow and very memory consuming 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 @@ -402,8 +402,8 @@ class RepoFilesView(RepoAppView): archive_dir_name = response_archive_name[:-len(ext)] use_cached_archive = False - archive_cache_enabled = CONFIG.get( - 'archive_cache_dir') and not self.request.GET.get('no_cache') + archive_cache_dir = CONFIG.get('archive_cache_dir') + archive_cache_enabled = archive_cache_dir and not self.request.GET.get('no_cache') cached_archive_path = None if archive_cache_enabled: @@ -421,13 +421,13 @@ class RepoFilesView(RepoAppView): # generate new archive, as previous was not found in the cache if not use_cached_archive: - - fd, archive = tempfile.mkstemp() + _dir = os.path.abspath(archive_cache_dir) if archive_cache_dir else None + fd, archive = tempfile.mkstemp(dir=_dir) log.debug('Creating new temp archive in %s', archive) try: commit.archive_repo(archive, archive_dir_name=archive_dir_name, kind=fileformat, subrepos=subrepos, - archive_at_path=at_path, with_hash=with_hash) + archive_at_path=at_path) except ImproperArchiveTypeError: return _('Unknown archive type') if archive_cache_enabled: diff --git a/rhodecode/lib/vcs/backends/base.py b/rhodecode/lib/vcs/backends/base.py --- a/rhodecode/lib/vcs/backends/base.py +++ b/rhodecode/lib/vcs/backends/base.py @@ -915,8 +915,9 @@ class BaseCommit(object): list of parent commits """ + repository = None + branch = None - branch = None """ Depending on the backend this should be set to the branch name of the commit. Backends not supporting branches on commits should leave this @@ -1193,7 +1194,7 @@ class BaseCommit(object): def archive_repo(self, archive_dest_path, kind='tgz', subrepos=None, archive_dir_name=None, write_metadata=False, mtime=None, - archive_at_path='/', with_hash=True): + archive_at_path='/'): """ Creates an archive containing the contents of the repository. @@ -1216,29 +1217,12 @@ class BaseCommit(object): (kind, allowed_kinds)) archive_dir_name = self._validate_archive_prefix(archive_dir_name) - mtime = mtime is not None or time.mktime(self.date.timetuple()) - - file_info = [] - cur_rev = self.repository.get_commit(commit_id=self.raw_id) - for _r, _d, files in cur_rev.walk(archive_at_path): - for f in files: - f_path = os.path.join(archive_dir_name, f.path) - file_info.append( - (f_path, f.mode, f.is_link(), f.raw_bytes)) + commit_id = self.raw_id - if write_metadata: - metadata = [ - ('repo_name', self.repository.name), - ('commit_id', self.raw_id), - ('mtime', mtime), - ('branch', self.branch), - ('tags', ','.join(self.tags)), - ] - meta = ["%s:%s" % (f_name, value) for f_name, value in metadata] - file_info.append(('.archival.txt', 0o644, False, '\n'.join(meta))) - - connection.Hg.archive_repo(archive_dest_path, mtime, file_info, kind) + return self.repository._remote.archive_repo( + archive_dest_path, kind, mtime, archive_at_path, + archive_dir_name, commit_id) def _validate_archive_prefix(self, archive_dir_name): if archive_dir_name is None: diff --git a/rhodecode/public/css/buttons.less b/rhodecode/public/css/buttons.less --- a/rhodecode/public/css/buttons.less +++ b/rhodecode/public/css/buttons.less @@ -264,7 +264,6 @@ input[type="button"] { margin-left: -1px; padding-left: 2px; padding-right: 2px; - border-left: 1px solid @grey3; } } diff --git a/rhodecode/templates/files/files_browser.mako b/rhodecode/templates/files/files_browser.mako --- a/rhodecode/templates/files/files_browser.mako +++ b/rhodecode/templates/files/files_browser.mako @@ -29,7 +29,7 @@
-