decaporg / decaporg/decap-cms

Images uploaded in a collection sub media_folder aren't deleted when they should

Open
#6,642 2 comments 2 reactions 0 assignees View on GitHub
area: asset-management area: media-library type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

When a `media_folder` and `public_folder` are used for a specific collection, the uploaded images for that collection aren't deleted when a collection item is deleted.

**To Reproduce**
1. Use the following config:
```yml
collections:
- name: posts
label: Posts
label_singular: 'Post'
folder: content/posts
path: '{{slug}}/index'
media_folder: ''
public_folder: ''
fields:
- label: Title
name: title
widget: string
- label: 'Cover Image'
name: 'image'
widget: 'image'
```
2. Create a post with an uploaded image
3. Delete the post
4. The `index.md` file is deleted, but the containing folder, including the uploaded image, are preserved.

**Expected behavior**
The image and folder structure of the post should be deleted too, since the image can't be referenced by other posts or any other collection items (See https://github.com/netlify/netlify-cms/issues/5910). For the same reason they can't be referenced everywhere else, they also cannot be deleted from anywhere else in netlify-cms.

**Applicable Versions:**
- Netlify CMS version: 2.15.72
- Git provider: Gitlab
- OS: macOS
- Browser version: Firefox 108.0.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.