You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(file-sme): preserve file attachments when updating metadata (Issue 405) (#764)
* fix(file-sme): preserve file attachments when updating metadata
Previously, updating a File submodel element via PUT would unconditionally delete the associated file, even when the file path (value) did not change. This commit introduces logic to detect whether the file path has actually changed before deleting the file.
Changes:
- Added path comparison logic using java.nio.file.Path to handle OS-specific path formats.
- Only delete attachments if the path has changed.
- Introduced helper methods for clarity and testability: isFileElement, extractFilePath, getExistingFilePath, pathsDiffer.
- Added robust exception handling and conservative fallback (delete if uncertain).
- Added structured SLF4J logging for traceability.
This resolves unintended data loss during metadata-only updates to File submodel elements.
* fix(file-sme): delete file attachment when replacing File with non-File element
Ensures that when a File submodel element is replaced by a non-File element (e.g., Property),
the previously attached file is properly deleted.
Copy file name to clipboardExpand all lines: basyx.submodelservice/basyx.submodelservice-backend/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/backend/CrudSubmodelService.java
0 commit comments