Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#5966 closed (wontfix)

FileField doesn't clean up directory after deletion

Reported by: Michiel_1981 Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: fs-rf-docs
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If a FileField file is being deleted it doesn't clean up a empty directory that might occur after deletion.
This is only a issue if you use a dynamic path based on date.

If this is the case then you could create a lot of empty directories and/or nested empty directories.
Example code:

class MetaFile(models.Model):
    file = models.FileField(_("File"), max_length=255,
                            upload_to='meta/%y/%m')

Attachments (0)

Change History (10)

comment:1 Changed 6 years ago by Gulopine

  • Keywords fs-rf added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by Gulopine

  • Keywords fs-rf-docs added; fs-rf removed

comment:3 Changed 6 years ago by MichaelBishop

  • Triage Stage changed from Unreviewed to Design decision needed

Why should an empty folder be delete after a file is deleted? I think that should be an individual design decision. However, a Django design decision is required.

comment:4 Changed 6 years ago by Gulopine

For what it's worth, when I added fs-rf-docs to this, it meant that my work on #5361 will make this behavior possible, but it won't be inclued by default. Instead, its documentation will show what hooks are available to make this happen. I'd also rather not see this behavior, but at least #5361 will make it possible for those who would like it. Just in case that helps with the design decision.

comment:5 Changed 6 years ago by Michiel_1981

for what it's worth, I override the FileField and add a dispather call to it for clean up if needed.
This ticket can be closed as you could override the delete method on the model or the above method.

I'll post on djangosnippets.org how this could be done if anybody is interested

comment:6 Changed 6 years ago by Gulopine

  • milestone set to 1.0 beta

comment:7 Changed 6 years ago by mir

  • milestone changed from 1.0 beta to post-1.0

Not considered a bug => not 1.0 beta.

comment:8 Changed 6 years ago by Gulopine

  • milestone changed from post-1.0 to 1.0 beta

Bugs aren't the only things planned for 1.0 beta. This is being addressed as part of #5361, which is planned to make it into 1.0 beta. Even though it won't be fixed directly, the behavior requested in this ticket will be quite possible once that goes in. Per Jacob, all such related tickets should be placed in the 1.0 beta milestone.

comment:9 Changed 6 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

File storage is in as of [8244], so I'm marking this as wontfix -- as Marty says, it's very easy to write a custom file storage backend that works exactly how you like it.

comment:10 Changed 3 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.