Loading src/tdoc_crawler/config/workspace_registry.py +8 −2 Original line number Diff line number Diff line Loading @@ -482,12 +482,17 @@ class WorkspaceRegistry: except (json.JSONDecodeError, KeyError) as e: logger.exception("Failed to load registry from %s: %s", registry_path, e) return cls._create_default(registry_path) # Return an empty in-memory registry — do NOT overwrite the file. # The user can fix or restore the file manually. return cls(registry_path=registry_path) @classmethod def _create_default(cls, registry_path: Path | None = None) -> WorkspaceRegistry: """Create a new registry with default workspace. Only writes to disk if the registry file does not already exist, to prevent accidental data loss. Args: registry_path: Optional explicit path to save to. Loading @@ -496,6 +501,7 @@ class WorkspaceRegistry: """ registry = cls(registry_path=registry_path) registry.create_workspace(DEFAULT_WORKSPACE, description="Default workspace") if registry_path is not None and not registry_path.exists(): registry.save() return registry Loading Loading
src/tdoc_crawler/config/workspace_registry.py +8 −2 Original line number Diff line number Diff line Loading @@ -482,12 +482,17 @@ class WorkspaceRegistry: except (json.JSONDecodeError, KeyError) as e: logger.exception("Failed to load registry from %s: %s", registry_path, e) return cls._create_default(registry_path) # Return an empty in-memory registry — do NOT overwrite the file. # The user can fix or restore the file manually. return cls(registry_path=registry_path) @classmethod def _create_default(cls, registry_path: Path | None = None) -> WorkspaceRegistry: """Create a new registry with default workspace. Only writes to disk if the registry file does not already exist, to prevent accidental data loss. Args: registry_path: Optional explicit path to save to. Loading @@ -496,6 +501,7 @@ class WorkspaceRegistry: """ registry = cls(registry_path=registry_path) registry.create_workspace(DEFAULT_WORKSPACE, description="Default workspace") if registry_path is not None and not registry_path.exists(): registry.save() return registry Loading