witten
/
luminotes
Archived
1
0
Fork 0

controller.Files.upload() now removes file data from disk upon an aborted upload.

Wiki.js Upload_pulldown() now has an update_position() method that's used when the pulldown is already open.
This commit is contained in:
Dan Helfman 2008-02-19 20:40:19 +00:00
parent ebf123d052
commit a34ffe2dc6
2 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,4 @@
import os
import cgi
import time
import tempfile
@ -88,6 +89,10 @@ class Upload_file( object ):
self.__file.close()
self.__complete.set()
def delete( self ):
self.__file.close()
os.remove( self.make_server_filename( self.__file_id ) )
def wait_for_complete( self ):
self.__complete.wait( timeout = cherrypy.server.socket_timeout )
@ -316,18 +321,20 @@ class Files( object ):
"""
global current_uploads, current_uploads_lock
if not self.__users.check_access( user_id, notebook_id, read_write = True ):
raise Access_error()
# write the file to the database
uploaded_file = current_uploads.get( file_id )
if not uploaded_file:
raise Upload_error()
if not self.__users.check_access( user_id, notebook_id, read_write = True ):
uploaded_file.delete()
raise Access_error()
content_type = upload.headers.get( "content-type" )
# if we didn't receive all of the expected data, abort
if uploaded_file.total_received_bytes < uploaded_file.content_length:
uploaded_file.delete()
raise Upload_error( "The upload did not complete." )
# record metadata on the upload in the database

View File

@ -2251,6 +2251,7 @@ Link_pulldown.prototype.shutdown = function () {
function Upload_pulldown( wiki, notebook_id, invoker, editor ) {
this.link = editor.find_link_at_cursor();
this.link.pulldown = this;
Pulldown.call( this, wiki, notebook_id, "upload_" + editor.id, this.link, editor.iframe );
wiki.down_image_button( "attachFile" );
@ -2342,9 +2343,14 @@ Upload_pulldown.prototype.upload_complete = function () {
this.shutdown();
}
Upload_pulldown.prototype.update_position = function ( anchor, relative_to ) {
Pulldown.prototype.update_position.call( this, anchor, relative_to );
}
Upload_pulldown.prototype.shutdown = function () {
Pulldown.prototype.shutdown.call( this );
this.wiki.up_image_button( "attachFile" );
if ( this.link )
this.link.pulldown = null;
}
function File_link_pulldown( wiki, notebook_id, invoker, editor, link ) {