Index: openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl,v diff -u -N -r1.21 -r1.22 --- openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 28 Apr 2005 22:38:06 -0000 1.21 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 4 Jun 2006 00:45:23 -0000 1.22 @@ -69,26 +69,30 @@ file { set path [cr_fs_path $storage_area_key] set filename [db_string write_file_content ""] - if { $string_p } { - set fd [open $filename "r"] - set text [read $fd] - close $fd - return $text + if {[empty_string_p $filename]} { + ad_return -code error "No content for the revision $revision_id. This seems to be an error which occured during the upload of the file" } else { - # JCD: for webdavfs there needs to be a content-length 0 header - # but ns_returnfile does not send one. Also, we need to - # ns_return size 0 files since if fastpath is enabled ns_returnfile - # simply closes the connection rather than send anything (including - # any headers). This bug is fixed in AOLServer 4.0.6 and later - # but work around it for now. - set size [file size $filename] - if {!$size} { - ns_set put [ns_conn outputheaders] "Content-Length" 0 - ns_return 200 text/plain {} - } else { - ns_returnfile 200 $mime_type $filename - } - } + if { $string_p } { + set fd [open $filename "r"] + set text [read $fd] + close $fd + return $text + } else { + # JCD: for webdavfs there needs to be a content-length 0 header + # but ns_returnfile does not send one. Also, we need to + # ns_return size 0 files since if fastpath is enabled ns_returnfile + # simply closes the connection rather than send anything (including + # any headers). This bug is fixed in AOLServer 4.0.6 and later + # but work around it for now. + set size [file size $filename] + if {!$size} { + ns_set put [ns_conn outputheaders] "Content-Length" 0 + ns_return 200 text/plain {} + } else { + ns_returnfile 200 $mime_type $filename + } + } + } } lob { @@ -190,17 +194,23 @@ set item_id [db_nextval acs_object_id_seq] } - # use content_type of existing item + # use content_type of existing item if $old_item_p { set content_type [db_string get_content_type ""] } else { - set content_type [cr_registered_type_for_mime_type $mime_type] + # all we really need to know is if the mime type is mapped to image, we + # actually use the passed in image_type or other_type to create the object + if {[db_string image_type_p "" -default 0]} { + set content_type image + } else { + set content_type content_revision + } } set revision_id [db_nextval acs_object_id_seq] db_transaction { - if { [empty_string_p [cr_registered_type_for_mime_type $mime_type]] } { + if { [empty_string_p [db_string is_registered "" -default ""]] } { db_dml mime_type_insert "" db_exec_plsql mime_type_register "" } @@ -216,8 +226,11 @@ if { [string equal $mime_type "image/jpeg"] } { catch { set what_aolserver_told_us [ns_jpegsize $tmp_filename] } } elseif { [string equal $mime_type "image/gif"] } { - catch { set what_aolserver_told_us [ns_gifsize $tmp_filename] } - } else { + catch { set what_aolserver_told_us [sn_gifsize $tmp_filename] } + } elseif { [string equal $mime_type "image/png"] } { + # we don't have built in png size detection + # but we want to allow upload of png images + } else { ad_return -code error "Unknown image type" }