Problem/Motivation

The FileUpdateService makes a call to file_move which has a default value of renaming the destination file if it already exists.

Meaning that subsequent calls to $plugin->updateUri($uri_new); would be referencing the existing file rather than the new (duplicate) one.

Steps to reproduce

Attempt to rename a file to a name which already exists on disk. The updates will be applied against the existing file name, rather than the current destination.

Proposed resolution

For now, updated the logic to ensure that it makes sure to read and reference the file URI returned from file_move.

In a newer update, an option may be added to allow users to customize the behaviour.
e.g. skipping the file move if it already exists (updating references only), overwriting or renaming.

Remaining tasks

Provide a PR.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

codebymikey created an issue. See original summary.

codebymikey’s picture

Status: Active » Needs review

Although the "default branch" is set to 1.0.x, I think it should be 1.x instead if following Drupal convention, as that's what the issue forks are based off by default.

https://www.drupal.org/node/1015226#semver-transition

So I've reapplied the changes from 1.0.x to 1.x.

edit: I've reapplied the MR to 1.0.x to make the review process easier.

codebymikey’s picture

jfeltkamp’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.