From b00beec3d26b7dff76b32d56078bf7c90eff915b Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 29 May 2024 17:44:55 +0200 Subject: [PATCH 1/2] Allow configuring hgweb repo prefix --- lib/galaxy/config/sample/tool_shed.yml.sample | 4 ++++ lib/galaxy/config/schemas/tool_shed_config_schema.yml | 8 ++++++++ lib/tool_shed/util/repository_util.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/config/sample/tool_shed.yml.sample b/lib/galaxy/config/sample/tool_shed.yml.sample index 3b04d57f94a7..e909ec253575 100644 --- a/lib/galaxy/config/sample/tool_shed.yml.sample +++ b/lib/galaxy/config/sample/tool_shed.yml.sample @@ -15,6 +15,10 @@ tool_shed: # installation directory. #hgweb_config_dir: null + # Default URL prefix for repositories served via hgweb. If running an + # external hgweb server you should set this to an empty string. + #hgweb_repo_prefix: repos/ + # Where Tool Shed repositories are stored. #file_path: database/community_files diff --git a/lib/galaxy/config/schemas/tool_shed_config_schema.yml b/lib/galaxy/config/schemas/tool_shed_config_schema.yml index 116f0521f483..47f97b1253c5 100644 --- a/lib/galaxy/config/schemas/tool_shed_config_schema.yml +++ b/lib/galaxy/config/schemas/tool_shed_config_schema.yml @@ -31,6 +31,14 @@ mapping: Where the hgweb.config file is stored. The default is the Galaxy installation directory. + hgweb_repo_prefix: + type: str + required: false + default: repos/ + desc: | + Default URL prefix for repositories served via hgweb. + If running an external hgweb server you should set this to an empty string. + file_path: type: str default: database/community_files diff --git a/lib/tool_shed/util/repository_util.py b/lib/tool_shed/util/repository_util.py index 9d9e805ae669..c84b182ae993 100644 --- a/lib/tool_shed/util/repository_util.py +++ b/lib/tool_shed/util/repository_util.py @@ -218,7 +218,7 @@ def create_repository( # Create the local repository. init_repository(repo_path=repository_path) # Add an entry in the hgweb.config file for the local repository. - lhs = f"repos/{repository.user.username}/{repository.name}" + lhs = f"{app.config.hgweb_repo_prefix}{repository.user.username}/{repository.name}" app.hgweb_config_manager.add_entry(lhs, repository_path) # Create a .hg/hgrc file for the local repository. create_hgrc_file(app, repository) From 410ccb9ab2218678e2ad878264812a2c4d3e155d Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 29 May 2024 17:45:23 +0200 Subject: [PATCH 2/2] Fix up lock handling in hgweb_config_manager --- lib/tool_shed/util/hgweb_config.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/tool_shed/util/hgweb_config.py b/lib/tool_shed/util/hgweb_config.py index f39d9abcc3d3..8c1656406b0f 100644 --- a/lib/tool_shed/util/hgweb_config.py +++ b/lib/tool_shed/util/hgweb_config.py @@ -19,11 +19,11 @@ class HgWebConfigManager: def __init__(self): self.hgweb_config_dir = None self.in_memory_config = None + self.lock = threading.Lock() def add_entry(self, lhs, rhs): """Add an entry in the hgweb.config file for a new repository.""" - lock = threading.Lock() - lock.acquire(True) + self.lock.acquire(True) try: # Since we're changing the config, make sure the latest is loaded into memory. self.read_config(force_read=True) @@ -38,12 +38,11 @@ def add_entry(self, lhs, rhs): except Exception as e: log.debug("Exception in HgWebConfigManager.add_entry(): %s", unicodify(e)) finally: - lock.release() + self.lock.release() def change_entry(self, old_lhs, new_lhs, new_rhs): """Change an entry in the hgweb.config file for a repository - this only happens when the owner changes the name of the repository.""" - lock = threading.Lock() - lock.acquire(True) + self.lock.acquire(True) try: self.make_backup() # Remove the old entry. @@ -55,7 +54,7 @@ def change_entry(self, old_lhs, new_lhs, new_rhs): except Exception as e: log.debug("Exception in HgWebConfigManager.change_entry(): %s", unicodify(e)) finally: - lock.release() + self.lock.release() def get_entry(self, lhs): """Return an entry in the hgweb.config file for a repository"""