Index: openacs-4/packages/acs-content-repository/acs-content-repository.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/acs-content-repository.info,v diff -u -r1.109.2.7 -r1.109.2.8 --- openacs-4/packages/acs-content-repository/acs-content-repository.info 1 Dec 2015 13:56:09 -0000 1.109.2.7 +++ openacs-4/packages/acs-content-repository/acs-content-repository.info 5 Jan 2016 14:55:50 -0000 1.109.2.8 @@ -7,7 +7,7 @@ t t - + OpenACS The canonical repository for OpenACS content. 2015-10-04 @@ -19,8 +19,9 @@ GPL 3 - + + Index: openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql,v diff -u -r1.10.18.1 -r1.10.18.2 --- openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql 2 Jan 2016 21:24:47 -0000 1.10.18.1 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs-postgresql.xql 5 Jan 2016 14:55:50 -0000 1.10.18.2 @@ -21,7 +21,7 @@ - select lob as content + select lob as content, 'lob' as storage_type from cr_revisions where revision_id = :revision_id 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 -r1.32.2.1 -r1.32.2.2 --- openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 10 Sep 2015 08:21:18 -0000 1.32.2.1 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 5 Jan 2016 14:55:50 -0000 1.32.2.2 @@ -110,11 +110,27 @@ if { $string_p } { return [db_blob_get write_lob_content ""] } - # need to set content_length header here - ns_set put [ns_conn outputheaders] "Content-Length" $content_length - ReturnHeaders $mime_type - # also need to check for HEAD method and skip sending - # actual content + + # + # Need to set content_length header here. + # + # Unfortunately, old versions of OpenACS did not set the + # content_length correctly, so we fix this here locally. + # + if {$content_length eq "0" && [db_driverkey ""] eq "postgresql"} { + set content_length [db_string get_lob_length { + select sum(byte_len) + from cr_revisions, lob_data + where revision_id = :revision_id and lob_id = cr_revisions.lob + }] + } + + ns_set put [ns_conn outputheaders] "Content-Length" $content_length + + ReturnHeaders $mime_type $content_length + # + # In a HEAD request, just send headers and no content + # if {![string equal -nocase "head" [ns_conn method]]} { db_write_blob write_lob_content "" } else { Index: openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl,v diff -u -r1.10.2.3 -r1.10.2.4 --- openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl 31 Dec 2015 17:35:48 -0000 1.10.2.3 +++ openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl 5 Jan 2016 14:55:50 -0000 1.10.2.4 @@ -13,7 +13,7 @@ # The size info is a valid geometry as provided for image magicks # "convert". We provide here a sample list of valid sizes # -if {$size ni {x24 x50 x100}} { +if {$size ne "" && $size ni {x24 x50 x100}} { ad_log warning "size '$size' is not supported" set size "" } @@ -26,28 +26,51 @@ } else { content::item::get -item_id $item_id -array_name itemInfo - if {$itemInfo(storage_type) eq "file"} { - # - # For portraits stored as files in the content repository, - # we provide cached thumbnails, which use in their cache - # key the revision id. - # + # + # For portraits stored as files in the content repository, + # we provide cached thumbnails, which use in their cache + # key the revision id. + # - set folder [acs_root_dir]/portrait-thumbnails - if {![file exists $folder]} { - file mkdir $folder - } + set folder [acs_root_dir]/portrait-thumbnails + if {![file exists $folder]} { + file mkdir $folder + } - set filename $folder/$itemInfo(revision_id).$size - - if {![file exists $filename]} { - set input_file [content::revision::get_cr_file_path -revision_id $itemInfo(revision_id)] - exec convert $input_file -resize $size $filename + set filename $folder/$itemInfo(revision_id).$size + + if {![file exists $filename]} { + switch $itemInfo(storage_type) { + "file" { + set input_file [content::revision::get_cr_file_path -revision_id $itemInfo(revision_id)] + exec convert $input_file -resize $size $filename + } + "lob" { + set input_file [ad_tmpnam] + set revision_id $itemInfo(revision_id) + # TODO: Oracle query and .xql is missing + db_blob_get_file write_lob_content { + select lob as content, 'lob' as storage_type + from cr_revisions + where revision_id = :revision_id + } -file $input_file + exec convert $input_file -resize $size $filename + file delete $input_file + } + default { + ad_log warning "unsupported storage type for portraits: $itemInfo(storage_type)" + } } - + } + # + # Test again if the file exists, we might have converted the + # file by the if-clause above. + # + if {[file exists $filename]} { ad_returnfile_background 200 $itemInfo(mime_type) $filename } else { - ad_log warning "Storage_type lob not handled" + ad_log warning "cannot show portrait with item_id $item_id for user $user_id " + ns_returnnotfound } } } Index: openacs-4/packages/acs-tcl/acs-tcl.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/acs-tcl.info,v diff -u -r1.70.2.8 -r1.70.2.9 --- openacs-4/packages/acs-tcl/acs-tcl.info 31 Dec 2015 17:02:42 -0000 1.70.2.8 +++ openacs-4/packages/acs-tcl/acs-tcl.info 5 Jan 2016 14:55:50 -0000 1.70.2.9 @@ -9,7 +9,7 @@ f t - + OpenACS The Kernel Tcl API library. 2015-10-04 @@ -18,7 +18,7 @@ GPL version 2 3 - + Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.140.2.20 -r1.140.2.21 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 31 Dec 2015 17:40:42 -0000 1.140.2.20 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 5 Jan 2016 14:55:50 -0000 1.140.2.21 @@ -1655,6 +1655,7 @@ ad_proc -private ReturnHeaders { {content_type text/html} + {content_length ""} } { We use this when we want to send out just the headers and then do incremental writes with ns_write. This way the user @@ -1664,13 +1665,14 @@ It returns status 200 and all headers including any added to outputheaders. } { - - if {[string match "text/*" $content_type] && ![string match "*charset=*" $content_type]} { + set text_p [string match "text/*" $content_type] + if {$text_p && ![string match "*charset=*" $content_type]} { append content_type "; charset=[ns_config ns/parameters OutputCharset iso-8859-1]" } if {[ns_info name] eq "NaviServer"} { - ns_headers 200 $content_type + set binary [expr {$text_p ? "" : "-binary"}] + ns_headers {*}$binary 200 $content_type {*}$content_length } else { set all_the_headers "HTTP/1.0 200 OK MIME-Version: 1.0