-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
needs reviewIssue needing input/review by the repo maintainer (Pixar)Issue needing input/review by the repo maintainer (Pixar)
Description
Description of Issue
If a layer's identifier changes, it is not marked dirty.
Line 5004 in 9b0c13b
| if (!force && !IsDirty() && TfPathExists(path)) |
SdfLayer::Save will early exit if a layer isn't dirty and if the resolved path exists on the file system. As such, it can report a successful save, even when the layer was not written.
We would recommend--
- Changing the identifier of a layer marks it as dirty
- Additionally, as of AR 2.0, it cannot be assumed that the resolved path is a file system path. Use
ArResolverinstead ofTfPathUtilsto arbitrate whether or not the layer exists already.
Steps to Reproduce
- Run the following python script. The only difference between the two blocks is that in the second block we touch the file path to ensure the file exists on disk.
import pathlib
import tempfile
from pxr import Sdf
from pxr import Usd
with tempfile.TemporaryDirectory() as temp_directory:
file_path = pathlib.Path(temp_directory) / "new_layer.sdf"
layer = Sdf.Layer.CreateAnonymous()
layer.identifier = str(file_path.absolute())
print("layer1>>", layer, file_path.exists(), layer.dirty)
print("layer1>>", layer.Save())
print("layer1>>", open(file_path).read())
with tempfile.TemporaryDirectory() as temp_directory:
file_path = pathlib.Path(temp_directory) / "new_layer.sdf"
file_path.touch()
layer = Sdf.Layer.CreateAnonymous()
layer.identifier = str(file_path.absolute())
print("layer2>>", layer, file_path.exists(), layer.dirty)
print("layer2>>", layer.Save())
print("layer2>>", open(file_path).read())
- You should see the following output. In both cases, the layer is not considered dirty. The only difference is whether or not the path exists already. Note that in both cases
Save()reports as being successful even though the contents of layer2 are empty.
layer1>> Sdf.Find('/tmp/tmph2n53a8g/new_layer.sdf') False False
layer1>> True
layer1>> #sdf 1.4.32
layer2>> Sdf.Find('/tmp/tmp2j4hxpbf/new_layer.sdf') True False
layer2>> True
layer2>>
System Information (OS, Hardware)
Linux
Package Versions
Build Flags
Metadata
Metadata
Assignees
Labels
needs reviewIssue needing input/review by the repo maintainer (Pixar)Issue needing input/review by the repo maintainer (Pixar)