Repository navigation
Description
BaseResourceManager.copy() (geonode/resource/manager.py) re-links each join-table keyed by the source resource's pk individually and by hand: keywords, regions, tkeywords, contacts (ContactRole), and LinkedResource. SparseField — the table backing custom/sparse metadata fields — isn't in that list and is never copied, so any custom metadata on the source resource is silently dropped from the clone.
Proposed fix
Replace the manual keywords/tkeywords/regions/contacts re-linking with the metadata manager's own schema machinery:
- Read the source resource's full metadata via
metadata_manager.build_schema_instance(instance, lang=None). - Write it onto the clone via
metadata_manager.update_schema_instance_partial(cloned_resource, schema_instance, user=owner)— the same callcreate()already uses forinfer_default_metadata.
Since every metadata handler (including the sparse-field handler) participates in building and applying that schema instance, this covers SparseField and any other handler-backed field generically, instead of requiring each new field type to be special-cased in copy() by hand.
Behavior change to call out explicitly: LinkedResource
The current manual code copies LinkedResource links in both directions:
- outgoing links where the source resource is the link's
source, and - incoming links where the source resource is the link's
target— in this case, it also adds a new link from the other resource to the clone (e.g. if Document D links to Map M, cloning M currently makes D link to the clone too).
LinkedResourceHandler (the metadata handler covering this field) only manages the outgoing direction. Switching to the schema-instance approach as described above would carry over outgoing links correctly but would stop propagating the incoming-direction relinking. This needs an explicit decision — keep that half as dedicated manual code alongside the schema-instance copy, or drop it as an intentional behavior change — rather than let it silently disappear as a side effect of the refactor.
Side notes
SparseFieldis also where migrated legacyExtraMetadatavalues now live (seegeonode/base/api/deprecated_extra_metadata.py), so today's bug incidentally drops those on clone too.- Metadata tracking is not yet implemented in
copy()
Activity
[-]Cloning resource does not copy custom metadata[/-][+]Cloning a resource does not copy its custom metadata[/+]