Q:

Why is file_managed not updated correctly? 

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',
  ])

When I create one contract adding a file (a.pages) to the entity, everything works as expected: a file with permanent status is added to file_managed table and appears in Files tab of content page:

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...

A:

I changed file.settings config entry make_unused_managed_files_temporary to true and it seems to do the job. 
Just hope there won't be any side effects...

