In a custom module (amap), I have a custom content entity (contract) created with Drupal Console.
There are standard CRUD functions on this entity.
One of the fields of the entity is a file field:
$fields['file1'] = BaseFieldDefinition::create('file') ->setLabel(t('Source file')) ->setDescription(t('Source file (may be modified)')) ->setSettings([ 'target_type' => 'file', 'file_extensions' => 'doc docx odt pages', 'uri_scheme' => 'private', 'file_directory' => 'contracts', ])
and the corresponding record is added to file_usage table:
My first problem appears when I want to update the contract changing the file (to Contract.doc, for example):
file_usage table is correctly updated: but file_managed table is not! The previous file (a.pages) is still there with permanent status.
The second problem is quite the same: when I delete the contract, file_usage table is correctly updated: there is no more record related to these files.
But file_managed table is not! The previous file (a.pages) is still there with permanent status (as in update mode).
My question is: is is normal?
Do I have to handle file_managed table myself?
Why is file_usage correctly updated and not file_managed?
I naively thought it was the case...