Index: openacs-4/contrib/obsolete-packages/bboard/sql/oracle/bboard-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard/sql/oracle/bboard-create.sql,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/contrib/obsolete-packages/bboard/sql/oracle/bboard-create.sql 13 Mar 2002 22:50:53 -0000 1.4 +++ openacs-4/contrib/obsolete-packages/bboard/sql/oracle/bboard-create.sql 6 Feb 2003 12:56:59 -0000 1.4.2.1 @@ -291,9 +291,6 @@ @@ bboard-packages -insert into cr_mime_types (mime_type) - values ('text/plain; format=flowed'); - set feedback on -- This was stolen from ACS 3.x www/doc/sql/site-wide-search.sql Index: openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-create.sql,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-create.sql 13 Mar 2002 22:50:53 -0000 1.5 +++ openacs-4/contrib/obsolete-packages/bboard/sql/postgresql/bboard-create.sql 6 Feb 2003 12:57:38 -0000 1.5.2.1 @@ -309,6 +309,7 @@ \i bboard-views.sql \i bboard-packages.sql -insert into cr_mime_types (mime_type) - values ('text/plain; format=flowed'); +-- Now created when content-repository loaded. +-- insert into cr_mime_types (mime_type) +-- values ('text/plain; format=flowed'); Index: openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.tcl,v diff -u -r1.9 -r1.9.4.1 --- openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.tcl 9 Mar 2002 02:00:02 -0000 1.9 +++ openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.tcl 6 Feb 2003 12:58:16 -0000 1.9.4.1 @@ -752,32 +752,6 @@ } } -ad_proc -public bboard_check_and_register_mime_type { - {type} -} { - This proc checks for or registers a mime_type in the content - repository type registry. -} { - # we don't do this as a transaction. - # or god forbid hold an exclusive lock - - # since if someone else adds this type at the same - # moment, we don't care. - - db_0or1row check_mime_type { - select mime_type - from cr_mime_types - where mime_type = :type - } - - if ![info exists mime_type] { - db_dml insert_mime { - insert into cr_mime_types (mime_type) - values (:type) - } - } -} - ad_proc -public bboard_attach_image { {-message_id:required} {-file_id ""} Index: openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.xql,v diff -u -r1.1 -r1.1.4.1 --- openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.xql 29 Jun 2001 20:33:23 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/bboard/tcl/bboard-procs.xql 6 Feb 2003 12:58:16 -0000 1.1.4.1 @@ -161,27 +161,6 @@ - - - - select mime_type - from cr_mime_types - where mime_type = :type - - - - - - - - - insert into cr_mime_types (mime_type) - values (:type) - - - - - Index: openacs-4/contrib/obsolete-packages/bboard/www/message-attach-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/bboard/www/message-attach-2.tcl,v diff -u -r1.2 -r1.2.2.1 --- openacs-4/contrib/obsolete-packages/bboard/www/message-attach-2.tcl 10 Sep 2002 22:22:24 -0000 1.2 +++ openacs-4/contrib/obsolete-packages/bboard/www/message-attach-2.tcl 6 Feb 2003 12:58:55 -0000 1.2.2.1 @@ -20,7 +20,7 @@ set user_id [ad_verify_and_get_user_id] # aolserver will give us a guessed mime type for the upload -set guessed_file_type [ns_guesstype $upload_file] +set guessed_file_type [cr_filename_to_mime_type $upload_file] # let us get the useful bits out of the long filename set full_filename ${upload_file.tmpfile} @@ -47,10 +47,6 @@ # insert the file into the database db_transaction { - - # check for and add MIME types missing from cr mime types table - bboard_check_and_register_mime_type $guessed_file_type - if { $file_ext == "jpeg" || $file_ext == "jpg" || $file_ext == "gif" } { set image_size [bboard_image_size $file_ext $upload_file] set width [lindex $image_size 0] 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.17.2.3 -r1.17.2.4 --- openacs-4/packages/acs-content-repository/acs-content-repository.info 3 Feb 2003 15:13:02 -0000 1.17.2.3 +++ openacs-4/packages/acs-content-repository/acs-content-repository.info 6 Feb 2003 12:52:46 -0000 1.17.2.4 @@ -7,7 +7,7 @@ t t - + oracle postgresql @@ -18,7 +18,7 @@ 2002-10-27 OpenACS - + @@ -60,6 +60,7 @@ + @@ -91,6 +92,7 @@ + Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-content-repository/sql/common/mime-type-data.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql,v diff -u -r1.16.2.2 -r1.16.2.3 --- openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql 3 Feb 2003 15:13:19 -0000 1.16.2.2 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql 6 Feb 2003 12:54:13 -0000 1.16.2.3 @@ -52,34 +52,26 @@ a file extension to the file after its MIME type is specified. '; --- Common mime types (administered from admin pages) +-- Currently file_extension is the pk although it seems likely someone +-- will want to support multiple mime types with the same extension. +-- Would need UI work however -insert into cr_mime_types(label, mime_type, file_extension) values ('Plain text', 'text/plain', 'txt'); -insert into cr_mime_types(label, mime_type, file_extension) values ('HTML text', 'text/html', 'html'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Rich Text Format (RTF)', 'text/richtext', 'rtf'); +create table cr_extension_mime_type_map ( + extension varchar(200) + constraint cr_mime_type_extension_map_pk + primary key, + mime_type varchar(200) + constraint cr_mime_ext_map_mime_type_ref + references cr_mime_types +); +create index cr_extension_mime_type_map_idx on cr_extension_mime_type_map(mime_type); -insert into cr_mime_types(label, mime_type, file_extension) values ('Binary', 'application/octet-stream', 'bin'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft Word', 'application/msword', 'doc'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft Excel', 'application/msexcel', 'xls'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft PowerPoint', 'application/powerpoint', 'ppt'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft Project', 'application/msproject', 'mpp'); -insert into cr_mime_types(label, mime_type, file_extension) values ('PostScript', 'application/postscript', 'ps'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Adobe Illustrator', 'application/x-illustrator', 'ai'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Adobe PageMaker', 'application/x-pagemaker', 'p65'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Filemaker Pro', 'application/filemaker', 'fm'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Image Pict', 'image/x-pict', 'pic'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Photoshop', 'application/x-photoshop', 'psd'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Acrobat', 'application/pdf', 'pdf'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Video Quicktime', 'video/quicktime', 'mov'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Video MPEG', 'video/mpeg', 'mpg'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio AIFF', 'audio/aiff', 'aif'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio Basic', 'audio/basic', 'au'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio Voice', 'audio/voice', 'voc'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio Wave', 'audio/wave', 'wav'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Archive Zip', 'application/zip', 'zip'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Archive Tar', 'application/z-tar', 'tar'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Unknown', '*/*', ''); +comment on table cr_extension_mime_type_map is ' + a mapping table for extension to mime_type in db version of ns_guesstype data +'; +-- Mime types and mappings defined in ../common/mime-type-data.sql + create table cr_content_mime_type_map ( content_type varchar2(100) constraint cr_content_mime_map_ctyp_fk @@ -811,18 +803,21 @@ prompt *** Compiling documentation package... @@ doc-package +prompt *** Loading mime type data ... +@ '../common/mime-type-data.sql' + prompt *** Creating image content type... @@ content-image --- by default, map all MIME types to 'content_revision' +-- map some MIME types to 'content_revision' begin content_type.register_mime_type( content_type => 'content_revision', mime_type => 'text/html'); content_type.register_mime_type( content_type => 'content_revision', mime_type => 'text/plain'); content_type.register_mime_type( - content_type => 'content_revision', mime_type => 'text/richtext'); + content_type => 'content_revision', mime_type => 'application/rtf'); end; / show errors Index: openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql,v diff -u -r1.4.4.1 -r1.4.4.2 --- openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 4 Oct 2002 08:27:32 -0000 1.4.4.1 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 6 Feb 2003 12:54:13 -0000 1.4.4.2 @@ -57,21 +57,6 @@ show errors --- insert new MIME types -insert into cr_mime_types ( - label, mime_type, file_extension -) values ( - 'Image - Jpeg', 'image/jpeg','jpg' -); - -insert into cr_mime_types ( - label, mime_type, file_extension -) values ( - 'Image - Gif', 'image/gif','gif' -); - - - -- register MIME types to this content type begin Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v diff -u -r1.36.2.3 -r1.36.2.4 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 3 Feb 2003 15:14:07 -0000 1.36.2.3 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 6 Feb 2003 12:54:54 -0000 1.36.2.4 @@ -37,10 +37,10 @@ - -------------------------------------------------------------- -- MIME TYPES -------------------------------------------------------------- +-- Mime data for the following table is in mime-type-data.sql create table cr_mime_types ( label varchar(200), @@ -60,34 +60,25 @@ a file extension to the file after its MIME type is specified. '; --- Common mime types (administered from admin pages) +-- Currently file_extension is the pk although it seems likely someone +-- will want to support multiple mime types with the same extension. +-- Would need UI work however -insert into cr_mime_types(label, mime_type, file_extension) values ('Plain text', 'text/plain', 'txt'); -insert into cr_mime_types(label, mime_type, file_extension) values ('HTML text', 'text/html', 'html'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Rich Text Format (RTF)', 'text/richtext', 'rtf'); +create table cr_extension_mime_type_map ( + extension varchar(200) + constraint cr_mime_type_extension_map_pk + primary key, + mime_type varchar(200) + constraint cr_mime_ext_map_mime_type_ref + references cr_mime_types +); +create index cr_extension_mime_type_map_idx on cr_extension_mime_type_map(mime_type); -insert into cr_mime_types(label, mime_type, file_extension) values ('Binary', 'application/octet-stream', 'bin'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft Word', 'application/msword', 'doc'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft Excel', 'application/msexcel', 'xls'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft PowerPoint', 'application/powerpoint', 'ppt'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Microsoft Project', 'application/msproject', 'mpp'); -insert into cr_mime_types(label, mime_type, file_extension) values ('PostScript', 'application/postscript', 'ps'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Adobe Illustrator', 'application/x-illustrator', 'ai'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Adobe PageMaker', 'application/x-pagemaker', 'p65'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Filemaker Pro', 'application/filemaker', 'fm'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Image Pict', 'image/x-pict', 'pic'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Photoshop', 'application/x-photoshop', 'psd'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Acrobat', 'application/pdf', 'pdf'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Video Quicktime', 'video/quicktime', 'mov'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Video MPEG', 'video/mpeg', 'mpg'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio AIFF', 'audio/aiff', 'aif'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio Basic', 'audio/basic', 'au'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio Voice', 'audio/voice', 'voc'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Audio Wave', 'audio/wave', 'wav'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Archive Zip', 'application/zip', 'zip'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Archive Tar', 'application/z-tar', 'tar'); -insert into cr_mime_types(label, mime_type, file_extension) values ('Unknown', '*/*', ''); +comment on table cr_extension_mime_type_map is ' + a mapping table for extension to mime_type in db version of ns_guesstype data +'; + create table cr_content_mime_type_map ( content_type varchar(100) constraint cr_content_mime_map_ctyp_fk @@ -1230,7 +1221,7 @@ PERFORM content_type__register_mime_type(''content_revision'', ''text/plain''); PERFORM content_type__register_mime_type(''content_revision'', - ''text/richtext''); + ''application/rtf''); v_id := content_folder__new ( ''pages'', @@ -1380,8 +1371,10 @@ add constraint cr_flder_pkg_id_fk foreign key (package_id) references apm_packages (package_id); --constraint cr_fldr_pkg_id_fk --- show errors +-- Load the mime type data. +\i ../common/mime-type-data.sql + -- prompt *** Preparing search indices... \i content-search.sql Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql,v diff -u -r1.7.2.2 -r1.7.2.3 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 21 Jan 2003 13:45:03 -0000 1.7.2.2 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 6 Feb 2003 12:54:54 -0000 1.7.2.3 @@ -59,22 +59,6 @@ end; - --- insert new MIME types -insert into cr_mime_types ( - label, mime_type, file_extension -) values ( - 'Image - Jpeg', 'image/jpeg','jpg' -); - -insert into cr_mime_types ( - label, mime_type, file_extension -) values ( - 'Image - Gif', 'image/gif','gif' -); - - - -- register MIME types to this content type begin; 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.7.2.1 -r1.7.2.2 --- openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 6 Dec 2002 12:29:14 -0000 1.7.2.1 +++ openacs-4/packages/acs-content-repository/tcl/revision-procs.tcl 6 Feb 2003 12:55:23 -0000 1.7.2.2 @@ -280,3 +280,90 @@ } { return [db_string registered_type_for_mime_type "" -default ""] } + + +ad_proc -public cr_filename_to_mime_type { + -create:boolean + filename +} { + given a filename, returns the mime type. If the -create flag is + given the mime type will be created; this assumes there is some + other way such as ns_guesstype to find the filename + + @param create flag whether to create the mime type the routine picks for filename + @param filename the filename to try to guess a mime type for (the file need not + exist, the routine does not attempt to access the file in any way) + + @return mimetype (or */* of unknown) + + @author Jeff Davis (davis@xarg.net) +} { + set extension [string tolower [string trimleft [file extension $filename] "."]] + + if {[empty_string_p $extension]} { + return "*/*" + } + + if {[db_0or1row lookup_mimetype { select mime_type from cr_extension_mime_type_map where extension = :extension }]} { + return $mime_type + } else { + set mime_type [string tolower [ns_guesstype $filename]] + ns_log Debug "guessed mime \"$mime_type\" create_p $create_p" + if {(!$create_p) || [string equal $mime_type "*/*"] || [empty_string_p $mime_type]} { + # we don't have anything meaningful for this mimetype + # so just */* it. + + return "*/*" + } + + # We guessed a type but there was no mapping + # create it and map it. We know the extension + cr_create_mime_type -extension $extension -mime_type $mime_type -description {} + + return $mime_type + } +} + +ad_proc -public cr_create_mime_type { + -extension + -mime_type + -description +} { + + Creates a mime type if it does not exist. Also maps extension to + mime_type (unless the extension is already mapped to another mime + type). + + @param extension the default extension for the given mime type + @param mime_type the mime_type to create + @param a plain text description of the mime type (< 200 characters) + + @author Jeff Davis (davis@xarg.net) +} { + # make both lower since that is the convention. + # should never pass in anything that is not lower cased + # already but just be safe. + + set mime_type [string tolower $mime_type] + set extension [string tolower $extension] + + db_dml maybe_create_mime { + insert into cr_mime_types (label, mime_type, file_extension) + select :description, :mime_type, :extension + from dual + where not exists (select 1 + from cr_mime_types + where mime_type = :mime_type) + } + + db_dml maybe_map_extension { + insert into cr_extension_mime_type_map (extension, mime_type) + select :extension, :mime_type + from dual + where not exists (select 1 + from cr_extension_mime_type_map + where extension = :extension) + } +} + + Index: openacs-4/packages/attachments/www/file-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/attachments/www/file-add-2.tcl,v diff -u -r1.2 -r1.2.2.1 --- openacs-4/packages/attachments/www/file-add-2.tcl 18 Sep 2002 13:07:14 -0000 1.2 +++ openacs-4/packages/attachments/www/file-add-2.tcl 6 Feb 2003 12:56:01 -0000 1.2.2.1 @@ -43,10 +43,7 @@ # Get the ip set creation_ip [ad_conn peeraddr] -# The content repository is kinda stupid about mime types, -# so we have to check if we know about this one and possibly -# add it. -set mime_type [fs_maybe_create_new_mime_type $upload_file] +set mime_type [cr_filename_to_mime_type -create $upload_file] # Get the storage type set indb_p [ad_parameter "StoreFilesInDatabaseP" -package_id [ad_conn package_id]] Index: openacs-4/packages/download/tcl/download-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/tcl/download-procs.tcl,v diff -u -r1.9 -r1.9.2.1 --- openacs-4/packages/download/tcl/download-procs.tcl 20 Sep 2002 22:40:41 -0000 1.9 +++ openacs-4/packages/download/tcl/download-procs.tcl 6 Feb 2003 12:59:37 -0000 1.9.2.1 @@ -177,36 +177,6 @@ return filter_return } -##Borrowed from file-storage -ad_proc download_maybe_create_new_mime_type { - file_name -} { - The content repository expects the MIME type to already be defined - when you upload content. We use this procedure to add a new type - when we encounter something we haven't seen before. -} { - - set mime_type [ns_guesstype $file_name] - set extension [string trimleft [file extension $file_name] "."] - - # don't know how to generate nice names like "JPEG Image" - # have to leave it blank for now - - #set pretty_mime_type ??? - - if { [db_string mime_type_exists " - select count(*) from cr_mime_types - where mime_type = :mime_type"] == 0 } { - db_dml new_mime_type " - insert into cr_mime_types - (mime_type, file_extension) - values - (:mime_type, :extension)" - } - - return $mime_type -} - # @author jbank@arsdigita.com [jbank@arsdigita.com] # @creation-date Fri Dec 15 14:07:02 2000 ad_proc download_metadata_column { data_type } { Dummy comment.} { @@ -335,7 +305,8 @@ # get the file_size for the postgres version set file_size [file size $tmpfile] - set mime_type [download_maybe_create_new_mime_type $upload_file] + set mime_type [cr_filename_to_mime_type -create $upload_file] + db_exec_plsql revision_new { declare v_revision_id integer; Index: openacs-4/packages/download/tcl/download-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/download/tcl/download-procs.xql,v diff -u -r1.3 -r1.3.4.1 --- openacs-4/packages/download/tcl/download-procs.xql 31 Oct 2001 20:42:07 -0000 1.3 +++ openacs-4/packages/download/tcl/download-procs.xql 6 Feb 2003 12:59:38 -0000 1.3.4.1 @@ -45,30 +45,6 @@ - - - -select count(*) from cr_mime_types -where mime_type = :mime_type - - - - - - - - - -insert into cr_mime_types -(mime_type, file_extension) -values -(:mime_type, :extension) - - - - - - Index: openacs-4/packages/file-storage/file-storage.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/file-storage.info,v diff -u -r1.17.2.2 -r1.17.2.3 --- openacs-4/packages/file-storage/file-storage.info 9 Dec 2002 22:43:07 -0000 1.17.2.2 +++ openacs-4/packages/file-storage/file-storage.info 6 Feb 2003 13:00:17 -0000 1.17.2.3 @@ -19,7 +19,7 @@ Now allows storage of files on the filesystem or database. - + Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v diff -u -r1.25 -r1.25.2.1 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 17 Sep 2002 21:03:26 -0000 1.25 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 6 Feb 2003 13:00:52 -0000 1.25.2.1 @@ -181,54 +181,6 @@ return $context_bar } -# -# Make sure we don't have page crashes due to unknown MIME types -# - -ad_proc fs_maybe_create_new_mime_type { - file_name -} { - The content repository expects the MIME type to already be defined - when you upload content. We use this procedure to add a new type - when we encounter something we haven't seen before. -} { - - set file_extension [string trimleft [file extension $file_name] "."] - - if {[empty_string_p $file_extension]} { - return "*/*" - } - - if {![db_0or1row select_mime_type "select mime_type - from cr_mime_types - where file_extension = :file_extension"]} { - - # A mime type for this file extension does not exist - # in the database. Check to see AOLServer can - # generate a mime type. - - set mime_type [ns_guesstype $file_name] - - # Note: If AOLServer can't determine a mime type, - # ns_guesstype will return */*. We still record - # a mime type for this file extension. At a later - # date, the mime type for the file extension may be - # updated and, as a result, the files with that - # file extension will be associated with the - # proper mime types. - - db_dml new_mime_type { - insert into cr_mime_types - (mime_type, file_extension) - values - (:mime_type, :file_extension) - } - } - return $mime_type -} - - - namespace eval fs { ad_proc -public new_root_folder { @@ -553,13 +505,7 @@ set cr_path [cr_fs_path $storage_area_key] set cr_file_name [db_string select_file_name {}] - set ifp [open "${cr_path}${cr_file_name}" r] - set ofp [open [file join ${path} ${file_name}] w] - - ns_cpfp $ifp $ofp - - close $ifp - close $ofp + file copy -- "${cr_path}${cr_file_name}" [file join ${path} ${file_name}] } } Index: openacs-4/packages/file-storage/tcl/file-storage-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.xql,v diff -u -r1.10 -r1.10.2.1 --- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 17 Sep 2002 21:03:26 -0000 1.10 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 6 Feb 2003 13:00:52 -0000 1.10.2.1 @@ -17,23 +17,6 @@ - - - select mime_type - from cr_mime_types - where file_extension = :file_extension - - - - - - insert into cr_mime_types - (mime_type, file_extension) - values - (:mime_type, :extension) - - - select item_id Index: openacs-4/packages/file-storage/www/file-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-add-2.tcl,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/file-storage/www/file-add-2.tcl 18 Sep 2002 12:09:59 -0000 1.6 +++ openacs-4/packages/file-storage/www/file-add-2.tcl 6 Feb 2003 13:01:35 -0000 1.6.2.1 @@ -41,10 +41,7 @@ # Get the ip set creation_ip [ad_conn peeraddr] -# The content repository is kinda stupid about mime types, -# so we have to check if we know about this one and possibly -# add it. -set mime_type [fs_maybe_create_new_mime_type $upload_file] +set mime_type [cr_filename_to_mime_type -create $upload_file] # Get the storage type set indb_p [ad_parameter "StoreFilesInDatabaseP" -package_id [ad_conn package_id]] Index: openacs-4/packages/file-storage/www/version-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/version-add-2.tcl,v diff -u -r1.2 -r1.2.4.1 --- openacs-4/packages/file-storage/www/version-add-2.tcl 22 Sep 2001 05:57:56 -0000 1.2 +++ openacs-4/packages/file-storage/www/version-add-2.tcl 6 Feb 2003 13:01:35 -0000 1.2.4.1 @@ -42,10 +42,8 @@ # Get the ip set creation_ip [ad_conn peeraddr] -# The content repository is kinda stupid about mime types, -# so we have to check if we know about this one and possibly -# add it. -set mime_type [fs_maybe_create_new_mime_type $upload_file] +# get mime type (create if needed) +set mime_type [cr_filename_to_mime_type -create $upload_file] # Get the storage type set indb_p [ad_parameter "StoreFilesInDatabaseP" -package_id [ad_conn package_id]] Index: openacs-4/packages/file-storage/www/doc/design.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/doc/design.html,v diff -u -r1.2 -r1.2.4.1 --- openacs-4/packages/file-storage/www/doc/design.html 25 Sep 2001 19:24:01 -0000 1.2 +++ openacs-4/packages/file-storage/www/doc/design.html 6 Feb 2003 13:02:28 -0000 1.2.4.1 @@ -347,23 +347,6 @@

-

fs_maybe_create_new_mime_type

fs_maybe_create_new_mime_type file_name
-
-The content repository expects the MIME type to already be defined - when you upload content. We use this procedure to add a new type - when we encounter something we haven't seen before. - -

-

-

Parameters:
-file_name
-
-
-
- -

- -

fs_root_folder

fs_root_folder [ -package_id package_id ]
Returns the root folder for the file storage system.