It does look like there might be a bug with how the directory watcher works in FAssetRegistry::OnDirectoryChanged
. We’ve likely never noticed this before as most of our packages only contain a single asset.
In the FFileChangeData::FCA_Modified
case, it marks the package for a re-scan without clearing out all the data associated with that package (like FFileChangeData::FCA_Removed
does), which could result in it leaving old asset data in the registry.
With regard to your use-case here, I’d be tempted to add a function which takes a UPackage*
and has the same behaviour as FFileChangeData::FCA_Removed
. You could then pass your package to it, the asset registry would clean up anything it thinks belonged to that package, and then you could use your calls to FAssetRegistry::AssetCreated
to re-populate it with the new assets.