witten
/
luminotes
Archived
1
0
Fork 0

Fixed a bug in which Files.purge_unused() deleted the file for a file link

that had a quote_filename parameter.
This commit is contained in:
Dan Helfman 2008-03-27 02:50:16 +00:00
parent 7cc155ac64
commit afe8c1227c
2 changed files with 28 additions and 1 deletions

View File

@ -213,7 +213,7 @@ cherrypy._cpcgifs.FieldStorage = FieldStorage
class Files( object ):
FILE_LINK_PATTERN = re.compile( u'<a\s+href="[^"]*/files/download\?file_id=([^"]+)">[^<]+</a>', re.IGNORECASE )
FILE_LINK_PATTERN = re.compile( u'<a\s+href="[^"]*/files/download\?file_id=([^"&]+)(&[^"]*)?">[^<]+</a>', re.IGNORECASE )
"""
Controller for dealing with uploaded files, corresponding to the "/files" URL.

View File

@ -1022,6 +1022,33 @@ class Test_files( Test_controller ):
assert db_file.filename == self.filename
assert Upload_file.exists( self.file_id )
def test_purge_unused_keep_file_with_quote_filename( self ):
self.login()
self.http_upload(
"/files/upload?file_id=%s" % self.file_id,
dict(
notebook_id = self.notebook.object_id,
note_id = self.note.object_id,
),
filename = self.filename,
file_data = self.file_data,
content_type = self.content_type,
session_id = self.session_id,
)
self.note.contents = '<a href="/files/download?file_id=%s&quote_filename=false">file link</a>' % self.file_id
self.database.save( self.note )
# the file is linked to from the note's contents, so this should not delete it
cherrypy.root.files.purge_unused( self.note )
db_file = self.database.load( File, self.file_id )
assert db_file
assert db_file.object_id == self.file_id
assert db_file.filename == self.filename
assert Upload_file.exists( self.file_id )
def test_purge_unused_all_links( self ):
self.login()