Modify

Opened 8 years ago

Last modified 8 years ago

#12644 new defect

Incompatibilty with new directorystructure and sha1-naming-convention for attachments (trac v1.0),

Reported by: brunodenys@… Owned by:
Priority: normal Component: SearchAttachmentsPlugin
Severity: major Keywords: sha1 filename
Cc: Trac Release: 1.0

Description (last modified by Jun Omae)

After some modifications to the 1.0 version of searchattachments.py the plugin was able to perform a search in wiki- and ticket-attachments in my environment (Windows, trac 1.0).

However, the resultset of the search returns links like:

Attachment::wiki/f09/f0955265d583361233790e2a4da795373c345a9f/f82e178298c44740723b7ee0c867cadcd29ff8a2.pdf

Indeed, as per t:#10313, the path is now rather based on message-digests of meaningfull words, than on readable words.

More-over, when clicking on such a link, an error-message appears saying there's no way to link to the attachment:

No handler matched request to 
/attachments/wiki/f09/f0955265d583361233790e2a4da795373c345a9f/f82e178298c44740723b7ee0c867cadcd29ff8a2.pdf

An approach would be to store the hash-based path in the database, this would allow a "reverse lookup" of the correct URL.

Attachments (4)

searchattachments.py (12.6 KB) - added by Bruno De Nys <brunodenys@…> 8 years ago.
modified to make it work under windows & trac 1.0 (at least in my environment).
searchattachments_for_windows_and_trac_v1.diff (5.8 KB) - added by brunodn 8 years ago.
patch file which makes searchattachments work with trac v1.0 under MS Windows. Not yet tested on another platform.
trac-seat_for_windows_and_trac_v1.diff (9.9 KB) - added by brunodn 8 years ago.
the trac-seat python script also needs some modifications to make it work in windows.
trac-seat_for_windows_and_trac_v1.2.diff (4.0 KB) - added by brunodn 8 years ago.
the trac-seat python script also needs some modifications to make it work in windows

Download all attachments as: .zip

Change History (9)

comment:1 Changed 8 years ago by Jun Omae

Description: modified (diff)
Keywords: sha1 added; MD5 handler removed
Severity: blockermajor

comment:2 Changed 8 years ago by Jun Omae

Summary: Incompatibilty with new directorystructure and MD5-namingconvention for attachments (trac v1.0),Incompatibilty with new directorystructure and sha1-naming-convention for attachments (trac v1.0),

Changed 8 years ago by Bruno De Nys <brunodenys@…>

Attachment: searchattachments.py added

modified to make it work under windows & trac 1.0 (at least in my environment).

comment:3 Changed 8 years ago by Bruno De Nys <brunodenys@…>

jun66j5: thanks for the corrections.

In attachment a modified searchattachemnts.py (cf. source:searchattachmentsplugin/1.0/searchattachments/searchattachments.py) which works under trac 1.0 in a Windows-environment. Modifications take into account:

  • using subprocess.Popen() instead of commands.getstatusoutput() (see #12645)
  • attachments-directory now is under directory named files.
Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:4 Changed 8 years ago by Jun Omae

Would you kindly create a patch file as described in ​t:TracDev/SubmittingPatches?

Also, shell=True should be removed.

According to https://docs.python.org/2/library/subprocess.html#using-the-subprocess-module:

Warning: Using shell=True can be a security hazard. See the warning under Frequently Used Arguments for details.

Changed 8 years ago by brunodn

patch file which makes searchattachments work with trac v1.0 under MS Windows. Not yet tested on another platform.

comment:5 in reply to:  4 Changed 8 years ago by brunodn

Replying to jun66j5:

Would you kindly create a patch file as described in ​t:TracDev/SubmittingPatches? ...

Pls. find attached a diff-file. Please note:

  • I have not been able to provide unit-tests, nor have I been able to test in a non-windows environment.
  • The code can most likely be improved (style-wise and performance-wise).
  • The No handler...error-message in the description was caused by the use of .../attachments/... instead of .../attachment/... in the URL. However, when using .../attachment/... the error-message becomes:
    Error: invalid attachment.
    Attachment 'wiki:f09/f0955265d583361233790e2a4da795373c345a9f: 4fed0572a8c466e1c654bdd27048b5c3bb1062be.PDF' does not exist.
    
  • The author of #10219 has made several suggestions to improve this plugin. It would be nice if some skilled developer would be able to port these to a trac version > 1.0.
Last edited 8 years ago by brunodn (previous) (diff)

Changed 8 years ago by brunodn

the trac-seat python script also needs some modifications to make it work in windows.

Changed 8 years ago by brunodn

the trac-seat python script also needs some modifications to make it work in windows

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


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

 
Note: See TracTickets for help on using tickets.