processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Filename does not get auto-incremented when file is added from current page's files directory

Open Toutouwai opened this issue 1 year ago • 2 comments

Short description of the issue

When adding a file whose filename is the same as an existing file belonging to the page, the added filename is automatically incremented. In the example below I've added an image from the home page's files directory.

2024-01-04_153427

But when the added file is from the current page's directory the filename is not auto-incremented, and this means that there is now a single file shared between two fields.

2024-01-04_152934

If the file is deleted from one field the other field now contains a missing asset.

2024-01-04_153008

Expected behavior

Filename is always auto-incremented if it clashes with a file that already exists, regardless of the path of the added file.

Setup/Environment

  • ProcessWire version: 3.0.233

Toutouwai avatar Jan 04 '24 02:01 Toutouwai

@Toutouwai PW determines whether to copy a file into its files directory based on whether it already exists in its directory or not. This directory is managed by PW and is not designed for something else copying stuff into it. I guess I think if something external is placing files into a PW managed directory then that's probably okay, but that tool would need to take care not to set these kinds of traps. Though if you don't see a way to avoid it, let me know and perhaps we can come up with something.

ryancramerdesign avatar Jan 19 '24 16:01 ryancramerdesign

This directory is managed by PW and is not designed for something else copying stuff into it.

The file isn't necessarily copied in by something other than PW. Here's another way of producing the same problem as described in the first post:

2024-01-22_144741

This seems like valid usage of the API and not something that should create a problem.

Toutouwai avatar Jan 22 '24 01:01 Toutouwai