Add Configuration for Replacing Instead of Renaming Files

Created on 24 January 2024, 11 months ago
Updated 13 May 2024, 7 months ago

Problem/Motivation

Multiple modules adds the functionality for replacing files instead of renaming them with a suffix like 'filename_0.pdf' including: Media Entity File Replace and File Field Replace . These are handling the files before this module moves the file, thus the setting for renaming/replacing is ignored.

File (Field) Path moves the file here at filefield_paths.inc::l.117 without using the third parameter $replace:
&& $new_file = \Drupal::service('file.repository')->move($file, $destination)

Proposed resolution

We could add the third argument to FileSystemInterface::move($source, $destination, $replace = self::EXISTS_RENAME) where the third parameter is: @param int $replace.
And thereby be something like:
&& $new_file = \Drupal::service('file.repository')->move($file, $destination, $replace)

The $replace variable could then be a configuration.

Feature request
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇩🇰Denmark nicklasmf

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024