Issue Bug Closed

#92734tables sys_file and sys_file_metadata should have a deleted flag

Stefan Busemann 10/29/20, 15:26 updated 11/19/26, 11:06

Description

If I delet a file via fllelist module, the file gets deleted (or move into the _recycler folder), but the sys_file and sys_file_metadata remain in the database tables untouched. If i unload later a file the same file identifier (same folder, same file_name), I will have duplicated entries in the table sys_file and sys_file_metadata.

AC:
  • sys_file and sys_file_metadata should get a deleted flag
  • the deleted flag should be set during deletion via filelist

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 3

  1. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-19T11:01:51+00:00" > 11/19/26, 11:01 </span>

    Thanks for the report. I checked this against the current main branch, and the duplicates described here no longer happen when a file is deleted through TYPO3:

    - If the storage has no recycler folder, deleting a file through the Filelist (ResourceStorage::deleteFile()) dispatches AfterFileDeletedEvent. Its listener FileDeletionAspect removes the sys_file record, its sys_file_metadata, processed files, category relations and all sys_file_reference records.
    - If a recycler folder exists, the file is moved there and its sys_file record moves with it, so the identifier changes. Uploading a new file with the same name to the original folder creates a new record without any collision.
    - Files removed outside TYPO3 (FTP, deployment) are flagged by the indexer with the existing missing field.

    Adding a deleted field to sys_file and sys_file_metadata would not help either. Once the file is removed from the storage, a record with deleted=1 points to nothing: the file can’t be restored or rendered from it, and references to it stay broken. Every FAL lookup would also have to filter it out. If you want deleted files to be restorable, use a recycler folder. It keeps both the file and its record.

    I’m closing this issue. If you can still get duplicate sys_file records on a current version, please post the exact steps (storage type, recycler folder yes or no, how the file was deleted) and we’ll reopen it.

  2. Benni Mack commented <span data-processor="relativetime" data-value="2026-11-19T11:06:01+00:00" > 11/19/26, 11:06 </span>

    Thanks for the report. I checked this against the current main branch, and the duplicates described here no longer happen when a file is deleted through TYPO3:

    • If the storage has no recycler folder, deleting a file through the Filelist (`ResourceStorage::deleteFile()`) dispatches `AfterFileDeletedEvent`. Its listener `FileDeletionAspect` removes the `sys_file` record, its `sys_file_metadata`, processed files, category relations and all `sys_file_reference` records.
    • If a `_recycler_` folder exists, the file is moved there and its `sys_file` record moves with it, so the identifier changes. Uploading a new file with the same name to the original folder creates a new record without any collision.
    • Files removed outside TYPO3 (FTP, deployment) are flagged by the indexer with the existing `missing` field.

    Adding a `deleted` field to `sys_file` and `sys_file_metadata` would not help either. Once the file is removed from the storage, a record with `deleted=1` points to nothing: the file can’t be restored or rendered from it, and references to it stay broken. Every FAL lookup would also have to filter it out. If you want deleted files to be restorable, use a `_recycler_` folder. It keeps both the file and its record.

    I’m closing this issue. If you can still get duplicate `sys_file` records on a current version, please post the exact steps (storage type, recycler folder yes or no, how the file was deleted) and we’ll reopen it.