Skip to content

Moving assets into a subfolder silently overwrites existing files #14381

@daun

Description

@daun

Bug description

When moving an asset to a subfolder, an existing asset with identical name in that folder is replaced by the moved asset. There is no warning, confirmation dialog, or other note about the other file existing or being replaced.

Also, moving the asset fails in Eloquent setups with a cryptic error message about unique key constraints because it tries to create the new asset in the db before moving it, and the unique key already exists. Most editors can't interpret the SQLite error message.

Ideally, there could be some sort of confirmation dialog, similar to the duplicate-filename upload confirmation.

Image Image

How to reproduce

Upload test.jpeg & move into folder.
Upload a different file also named test.jpeg & move into folder.
Open folder; only the second uploaded file is inside.

The example is a bit silly because of the manual renaming. In practice, we found this through a user who was cleaning up asset folders and moving multiple files named logo.svg from different folders into a single subfolder.

Image

Logs

Environment

Environment
Laravel Version: 12.56.0
PHP Version: 8.4.3
Composer Version: 2.8.3
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: database
Session: file

Storage
public/storage: NOT LINKED

Statamic
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.x-dev PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions