cms icon indicating copy to clipboard operation
cms copied to clipboard

Assets are overwritten when they have the same name after rename

Open o1y opened this issue 2 years ago • 3 comments

Bug description

While uploading and renaming files through the Assets Browser, I accidentally used for multiple files the same filename, which caused Statamic to override the existing file with the new one.

How to reproduce

2023-04-30 12 40 15

  1. Upload a file. Rename this file to test 1
  2. Upload a second file. Rename this file to test 1

Result: The first file gets ovewritten by the second file.

After clicking Rename on the second file, I'm getting a Vue error, see below.

Logs

[Vue warn]: Error in event handler for "editor-action-selected": "TypeError: this.findActionComponent(...) is undefined"

TypeError: this.findActionComponent(...) is undefined
    actionSelected EditorActions.vue:51
    VueJS 2
    runAction Editor.vue:404
    click Editor.vue:343
    VueJS 48
    load Editor.vue:297
    promise callback*load Editor.vue:295
    mounted Editor.vue:271
    VueJS 19
    edit Browser.vue:550
    editAsset AssetManager.vue:130
    VueJS 4
    click Browser.vue:436
    VueJS 2

Environment

Environment
Application Name: Statamic
Laravel Version: 9.52.5
PHP Version: 8.2.5
Composer Version: 2.4.4
Environment: local
Debug Mode: ENABLED
URL: statamic-v3.4.test
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.7 PRO

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

Issue #6667 could be related.

o1y avatar Apr 30 '23 10:04 o1y

Hey 👋

I'm unable to reproduce this issue on the latest version of Statamic. It looks like -1 is appended to the filename to prevent the renamed asset from overwriting the existing one:

CleanShot 2024-01-09 at 16 16 20

I'm going to close this issue now. If you're still experiencing this issue, please leave a comment and we can re-open the issue. Thanks!

duncanmcclean avatar Jan 09 '24 16:01 duncanmcclean

Yes, still experiencing this issue. You forgot the first step in your test. You need to rename the first asset directly after uploading.

  1. Upload a file. Rename this file directly after the upload to test 1
  2. Upload a second file. Rename this file to test 1

o1y avatar Jan 09 '24 16:01 o1y

I see it now, thanks! I must have missed that part.

duncanmcclean avatar Jan 09 '24 16:01 duncanmcclean