Problem/Motivation
There is a weird quirk: First upload of a file fails if the file is registered in the the table {file_managed}
, even if it does not exist in the file system. Second attempt works.
Steps to reproduce
I am unable to reproduce this in a consistent manner. When I upload a file attachment to a node, it gets registered in the table {file_managed}
, when I return to the attachement, and press "Remove" and save the node, it sometimes gets removed from the file system, and the table {file_managed}
. However, sometimes it is not removed.
However, this is done by core. It has nothing to do with this module.
Supposed a file (original name "'blå Bær.png'
) is registered in the table {file_managed}
, correctly transliterated to "bla_baer.png
" and you try to upload the file as a file attachment to a node, you'll get this error:
The specified file blå Bær.png could not be uploaded.
The file public://2021-11/blå Bær.png already exists. Enter a unique file URI.
Inspecting the file directory using the CLI shows that it has been uploaded, but not transliterated.
Then try to upload the same file again. I now get:
Your upload has been renamed to blå Bær_0.png.
Note that the message does not show the correct transliterated name.
However inspecting the file directory using the CLI shows that the name has been correctly transliterated - its name is "bla_baer_0.png".
Proposed resolution
As noted above, the problem lies outside this module, and is caused by some quirk in core I am unable to reproduce consistently.
However, I think a mention of this quirk, and its cause in the README.md would help those that run into this quirk.