Django

Code

Ticket #5966 (closed: wontfix)

Opened 2 years ago

Last modified 2 years ago

FileField doesn't clean up directory after deletion

Reported by: Michiel_1981 Assigned to: nobody
Milestone: 1.0 beta Component: Core framework
Version: SVN Keywords: fs-rf-docs
Cc: Triage Stage: Design decision needed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Change History

12/11/07 12:00:54 changed by Gulopine

  • keywords set to fs-rf.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

12/17/07 20:52:07 changed by Gulopine

  • keywords changed from fs-rf to fs-rf-docs.

03/17/08 12:01:01 changed by MichaelBishop

  • 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.

03/17/08 12:31:53 changed 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.

03/17/08 14:22:38 changed 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

06/16/08 13:30:30 changed by Gulopine

  • milestone set to 1.0 beta.

07/29/08 05:24:19 changed by mir

  • milestone changed from 1.0 beta to post-1.0.

Not considered a bug => not 1.0 beta.

07/29/08 06:30:22 changed 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.

08/08/08 16:03:31 changed by jacob

  • status changed from new to closed.
  • resolution set to wontfix.

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.


Add/Change #5966 (FileField doesn't clean up directory after deletion)




Change Properties
Action