Edgewall Software

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#11741 closed defect (fixed)

Renaming a wiki page with attachments does not delete the old name attachment folder — at Version 5

Reported by: Francesca Mazzoni <francesca.mazzoni@…> Owned by: Jun Omae
Priority: normal Milestone: 0.12.7
Component: attachment Version: 0.12.5
Severity: minor Keywords:
Cc: Branch:
Release Notes:

Fix not deleting the old attachment directory when wiki page is renamed.

API Changes:
Internal Changes:

Description (last modified by Jun Omae)

I'm on Debian stable with Python 2.7.3 and installed from Debian package.

When I rename a Wiki page that contains attachments, the (empty) folder in which the attachments were stored before the page renaiming is still in the file system.

Steps to reproduce:

1) Create a new wiki page (say MyOldPage), add an attachment (say MyAttach.tgz). The attached file is stored in <trac-env>/attachments/wiki/MyOldPage/MyAttach.tgz.

2) Rename MyOldPage to MyNewPage.

The attachments are now (correctly) stored in <trac-env>/attachments/wiki/MyNewPage/.

I still have the <trac-env>/attachments/wiki/MyOldPage folder.

I think that the folder should be removed, since it is empty.

Change History (5)

comment:1 by Jun Omae, 10 years ago

Component: wiki systemattachment
Description: modified (diff)
Keywords: attachment removed

comment:2 by Jun Omae, 10 years ago

Milestone: 0.12.7
Owner: set to Jun Omae
Status: newassigned

Thanks for the report. Reproduced on 0.12-stable. The following patch would fix it.

  • trac/attachment.py

    diff --git a/trac/attachment.py b/trac/attachment.py
    index af1a71d..040214e 100644
    a b class Attachment(object):  
    348348        def do_reparent(db):
    349349            for attachment in list(cls.select(env, parent_realm, parent_id,
    350350                                              db)):
    351                 attachment_dir = os.path.dirname(attachment.path)
     351                attachment_dir[0] = os.path.dirname(attachment.path)
    352352                attachment.reparent(new_realm, new_id)
    353353        if attachment_dir[0]:
    354354            try:

I'll push the patch with unit test on 0.12.7.

comment:3 by Jun Omae, 9 years ago

This issue occurs on only 0.12.x. Milestone 0.12.7 for only security fixes. But this issue is not a security issue. Should we fix it? or leave it?

comment:4 by Ryan J Ollos, 9 years ago

My feeling is that it is really up to you, particularly since we've committed to at least one more release from the 0.12-stable branch. I'd probably go ahead and push the fix though if I had any use for 0.12.x.

After we do the 0.12.7 release though, if we are treating it as a security-fix only branch then future releases will only be as needed.

comment:5 by Jun Omae, 9 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Thanks for the comments. Fixed in [13610] and recorded only in [13611-13612].

Note: See TracTickets for help on using tickets.