Migrate file not replacing files having same file name

Created on 18 April 2024, 12 months ago

Problem/Motivation

During migration if the files name are same in both source and destination it is not replacing the old file with the new one.

Proposed resolution

For now adding timestamp value to create the new file if the source and destination file name is same. We need to delete the old file as well.

🐛 Bug report
Status

Needs work

Version

2.1

Component

Code

Created by

🇮🇳India S_Bhandari

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

Comments & Activities

  • Issue created by @S_Bhandari
  • Status changed to Needs review 12 months ago
  • 🇩🇪Germany Duwid

    You can just use file_exists: rename for this.

    - file_exists: (optional) Replace behavior when the destination file already
       exists:
       - 'replace' - (default) Replace the existing file.
       - 'rename' - Append _{incrementing number} until the filename is
           unique.
       - 'use existing' - Do nothing and return FALSE.

    Example:

      field_images:
        plugin: file_import
        source: images
        destination: constants/image_destination
        skip_on_missing_source: true
        file_exists: rename
  • 🇩🇪Germany Duwid

    I can confirm that file_exists: replace works as well. Images with the same filenames are replaced correctly, but the old image styles were not flushed. See issue #3420449 🐛 Flush image styles when replace is used Needs review

Production build 0.71.5 2024