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:
parent
ebf123d052
commit
a34ffe2dc6
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import cgi
|
import cgi
|
||||||
import time
|
import time
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -88,6 +89,10 @@ class Upload_file( object ):
|
||||||
self.__file.close()
|
self.__file.close()
|
||||||
self.__complete.set()
|
self.__complete.set()
|
||||||
|
|
||||||
|
def delete( self ):
|
||||||
|
self.__file.close()
|
||||||
|
os.remove( self.make_server_filename( self.__file_id ) )
|
||||||
|
|
||||||
def wait_for_complete( self ):
|
def wait_for_complete( self ):
|
||||||
self.__complete.wait( timeout = cherrypy.server.socket_timeout )
|
self.__complete.wait( timeout = cherrypy.server.socket_timeout )
|
||||||
|
|
||||||
|
@ -316,18 +321,20 @@ class Files( object ):
|
||||||
"""
|
"""
|
||||||
global current_uploads, current_uploads_lock
|
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
|
# write the file to the database
|
||||||
uploaded_file = current_uploads.get( file_id )
|
uploaded_file = current_uploads.get( file_id )
|
||||||
if not uploaded_file:
|
if not uploaded_file:
|
||||||
raise Upload_error()
|
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" )
|
content_type = upload.headers.get( "content-type" )
|
||||||
|
|
||||||
# if we didn't receive all of the expected data, abort
|
# if we didn't receive all of the expected data, abort
|
||||||
if uploaded_file.total_received_bytes < uploaded_file.content_length:
|
if uploaded_file.total_received_bytes < uploaded_file.content_length:
|
||||||
|
uploaded_file.delete()
|
||||||
raise Upload_error( "The upload did not complete." )
|
raise Upload_error( "The upload did not complete." )
|
||||||
|
|
||||||
# record metadata on the upload in the database
|
# record metadata on the upload in the database
|
||||||
|
|
|
@ -2251,6 +2251,7 @@ Link_pulldown.prototype.shutdown = function () {
|
||||||
|
|
||||||
function Upload_pulldown( wiki, notebook_id, invoker, editor ) {
|
function Upload_pulldown( wiki, notebook_id, invoker, editor ) {
|
||||||
this.link = editor.find_link_at_cursor();
|
this.link = editor.find_link_at_cursor();
|
||||||
|
this.link.pulldown = this;
|
||||||
|
|
||||||
Pulldown.call( this, wiki, notebook_id, "upload_" + editor.id, this.link, editor.iframe );
|
Pulldown.call( this, wiki, notebook_id, "upload_" + editor.id, this.link, editor.iframe );
|
||||||
wiki.down_image_button( "attachFile" );
|
wiki.down_image_button( "attachFile" );
|
||||||
|
@ -2342,9 +2343,14 @@ Upload_pulldown.prototype.upload_complete = function () {
|
||||||
this.shutdown();
|
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 () {
|
Upload_pulldown.prototype.shutdown = function () {
|
||||||
Pulldown.prototype.shutdown.call( this );
|
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 ) {
|
function File_link_pulldown( wiki, notebook_id, invoker, editor, link ) {
|
||||||
|
|
Reference in New Issue