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
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | file_update-use-appropriate-destination-file-3214405-4.diff | 11.01 KB | codebymikey |
Issue fork file_update-3214405
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
Comment #3
codebymikey commentedAlthough the "default branch" is set to1.0.x, I think it should be1.xinstead if following Drupal convention, as that's what the issue forks are based off by default.https://www.drupal.org/node/1015226#semver-transitionSo I've reapplied the changes from1.0.xto1.x.edit: I've reapplied the MR to
1.0.xto make the review process easier.Comment #4
codebymikey commentedComment #6
jfeltkamp