Skip to content

Layer Cannot Be Saved When Identifier Changes for Crate Files #3975

@nvmkuruc

Description

@nvmkuruc

We had reported in #3386 that layers are not marked dirty when the identifier changes and provided a repro using sdf. Because the layer is not marked dirty, the layer fails to save.

A fix was provided with these commits:
61899b6
76c6f5d

@roggiezhang-nv has observed that the fix doesn't work for usdc. We've provided a new repro below which demonstrates that a renamed usdc layer cannot be saved.

# repro.py
import pathlib
import tempfile

from pxr import Sdf
from pxr import Usd

with tempfile.TemporaryDirectory() as temp_directory:
    for file_format in (".usda", ".usdc"):
        file_path = (pathlib.Path(temp_directory) / "new_layer").with_suffix(file_format)
        renamed_file_path = (file_path.parent / "renamed_layer").with_suffix(file_format)
        layer = Sdf.Layer.CreateNew(str(file_path.absolute()))
        print(f"new_layer[{file_format}]>>", layer, layer.dirty)
        print(f"new_layer[{file_format}]>>", layer.Save())
        assert file_path.exists()
        assert not renamed_file_path.exists()
        layer.identifier = str(renamed_file_path.absolute())
        print(f"renamed_layer[{file_format}]>>", layer, layer.dirty)
        print(f"renamed_layer[{file_format}]>>", layer.Save())

repro.py was evaluated using the following command on Linux.

uv run --with usd-core==25.11 --python 3.12 python3 repro.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions