From e49f31322cfd964b29dd04e36b11568846aa1720 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 14 May 2026 10:07:03 +0200 Subject: [PATCH] Redirect blob to tree page if target is a tree --- RNS/Utilities/rngit/pages.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/RNS/Utilities/rngit/pages.py b/RNS/Utilities/rngit/pages.py index e5eec25d..a5683702 100644 --- a/RNS/Utilities/rngit/pages.py +++ b/RNS/Utilities/rngit/pages.py @@ -689,6 +689,10 @@ class NomadNetworkNode(): if blob_info is None: content_parts.append("File not found at this ref.\n") else: + # Redirect to tree page if this is a tree + if blob_info.get("is_tree", None) == True: + return self.serve_tree_page(path, data, request_id, link_id, remote_identity, requested_at) + size = blob_info.get("size", 0) is_binary = blob_info.get("is_binary", False) is_symlink = blob_info.get("is_symlink", False) @@ -1846,6 +1850,15 @@ class NomadNetworkNode(): size = int(result.stdout.strip()) + # Check if it's a tree via ls-tree + check_tree_path = f"{ref}:{file_path}" if file_path else ref + result = subprocess.run(["git", "ls-tree", check_tree_path], + cwd=repo_path, capture_output=True, text=True, + timeout=self.GIT_COMMAND_TIMEOUT, check=False) + + if result.returncode == 0: is_tree = True + else: is_tree = False + # Check if it's a symlink via ls-tree parent_dir = "/".join(file_path.split("/")[:-1]) filename = file_path.split("/")[-1] @@ -1894,6 +1907,7 @@ class NomadNetworkNode(): if first_line.startswith("-"): is_binary = True return { "size": size, + "is_tree": is_tree, "is_binary": is_binary, "is_symlink": is_symlink, "symlink_target": symlink_target }