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.2 -r1.3 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 4 Sep 2001 01:27:51 -0000 1.2 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 22 Sep 2001 05:40:13 -0000 1.3 @@ -32,7 +32,7 @@ } { return [db_exec_plsql folder_name " begin - :1 := content_folder.get_label(:folder_id); + :1 := file_storage.get_folder_name(:folder_id); end;"] } @@ -167,20 +167,20 @@ set start_id [db_string parent_id " select parent_id from cr_items where item_id = :item_id"] set final [db_exec_plsql title "begin - :1 := content_item.get_title(:item_id); + :1 := file_storage.get_title(:item_id); end;"] } else { set start_id $item_id } set context_bar [db_list_of_lists context_bar " select decode( - content_item.get_content_type(i.item_id), + file_storage.get_content_type(i.item_id), 'content_folder', - '?folder_id=', + 'index?folder_id=', 'file?file_id=' ) || i.item_id, - content_item.get_title(i.item_id) + file_storage.get_title(i.item_id) from cr_items i where item_id not in ( select i2.item_id Index: openacs-4/packages/file-storage/www/file-add-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-add-2-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/file-storage/www/file-add-2-oracle.xql 4 Sep 2001 01:28:59 -0000 1.2 +++ openacs-4/packages/file-storage/www/file-add-2-oracle.xql 22 Sep 2001 05:41:51 -0000 1.3 @@ -3,33 +3,50 @@ oracle8.1.6 - + begin - :1 := content_item.new ( - name => :filename, - parent_id => :folder_id, - context_id => :folder_id, + :1 := file_storage.new_file ( + title => :title, + folder_id => :folder_id, creation_user => :user_id, creation_ip => :creation_ip, - item_subtype => 'file_storage_item' -- Needed by site-wide search + indb_p => 't' ); end; - - + + begin - :1 := content_revision.new ( + :1 := file_storage.new_file ( title => :title, + folder_id => :folder_id, + creation_user => :user_id, + creation_ip => :creation_ip, + indb_p => 'f' + ); + + end; + + + + + + + + + begin + :1 := file_storage.new_version ( + filename => :filename, description => :description, mime_type => :mime_type, - item_id => :item_id, + item_id => :file_id, creation_user => :user_id, creation_ip => :creation_ip ); @@ -40,24 +57,36 @@ - + update cr_revisions set content = empty_blob() - where revision_id = :revision_id + where revision_id = :version_id returning content into :1 - - + + + update cr_revisions + set content_length = dbms_lob.getlength(content) + where revision_id = :version_id + + + + + + + -begin - content_item.set_live_revision(:revision_id); -end; + update cr_revisions + set filename = '$tmp_filename', + content_length = $tmp_size + where revision_id = :version_id + Index: openacs-4/packages/file-storage/www/file-add-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-add-2-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/file-storage/www/file-add-2-postgresql.xql 4 Sep 2001 01:29:19 -0000 1.2 +++ openacs-4/packages/file-storage/www/file-add-2-postgresql.xql 22 Sep 2001 05:42:03 -0000 1.3 @@ -3,70 +3,85 @@ postgresql7.1 - + - select content_item__new ( - :filename, -- name - :folder_id, -- parent_id - null, -- item_id (default) - null, -- locale (default) - now(), -- creation_date (default) - :user_id, -- creation_user - :folder_id, -- context_id - :creation_ip, -- creation_ip - 'file_storage_item', -- item_subtype (needed by site-wide search) - 'content_revision', -- content_type (default) - null, -- title (default) - null, -- description - 'text/plain', -- mime_type (default) - null, -- nls_language (default) - null -- data (default) - ); + select file_storage__new_file ( + :title, -- title + :folder_id, -- parent_id + :user_id, -- creation_user + :creation_ip, -- creation_ip + true -- indb_p + ); + - - + - select content_revision__new ( - :title, -- title - :description, -- description - now(), -- publish_date - :mime_type, -- mime_type - null, -- nls_language - null, -- data (default) - :item_id, -- item_id - null, -- revision_id - now(), -- creation_date - :user_id, -- creation_user - :creation_ip -- creation_ip - ); + select file_storage__new_file ( + :title, -- title + :folder_id, -- parent_id + :user_id, -- creation_user + :creation_ip, -- creation_ip + false -- indb_p + ); - + + select file_storage__new_version ( + :filename, -- filename + :description, -- description + :mime_type, -- mime_type + :file_id, -- item_id + :user_id, -- creation_user + :creation_ip -- creation_ip + ); + + + + + + + + update cr_revisions set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] - where revision_id = :revision_id + where revision_id = :version_id - - + - select content_item__set_live_revision(:revision_id); + update cr_revisions + set content_length = lob_length(lob) + where revision_id = :version_id - + - + + + + + + update cr_revisions + set content = '$tmp_filename', + content_length = $tmp_size + where revision_id = :version_id + + + + + + Index: openacs-4/packages/file-storage/www/download/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/download/Attic/index-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/file-storage/www/download/index-postgresql.xql 17 Aug 2001 01:26:48 -0000 1.1 +++ openacs-4/packages/file-storage/www/download/index-postgresql.xql 22 Sep 2001 05:41:04 -0000 1.2 @@ -17,7 +17,7 @@ - + select r.lob as content, i.storage_type @@ -27,4 +27,28 @@ + + + + + select '[cr_fs_path]' || r.content, i.storage_type + from cr_revisions r, cr_items i + where r.item_id = i.item_id + and r.revision_id = :version_id + + + + + + + + select mime_type,(case when lob is null then 0 + else 1 + end) as indb_p + from cr_revisions + where revision_id = :version_id + + + + Index: openacs-4/packages/file-storage/www/download/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/download/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/file-storage/www/download/index.vuh 20 Apr 2001 20:51:10 -0000 1.1 +++ openacs-4/packages/file-storage/www/download/index.vuh 22 Sep 2001 05:41:18 -0000 1.2 @@ -1,4 +1,4 @@ -# packages/file-storage/www/download.vuh +# packages/file-storage/www/download/index.vuh ad_page_contract { @@ -13,25 +13,49 @@ set user_id [ad_conn user_id] -regexp "[ad_conn package_url]download/(.*)" [ad_conn url] match path +# There is really no point in resolving the live_revision from the path, +# since we can always pass the live_revision id! +# +#regexp "[ad_conn package_url]download/(.*)" [ad_conn url] match path +# +#if [empty_string_p $version_id] { +# if ![db_0or1row get_file_id " +# select content_item.get_live_revision(content_item.get_id(:path,file_storage.get_root_folder([ad_conn package_id]))) as version_id from dual"] { +# ad_script_abort +# } +#} -if [empty_string_p $version_id] { - if ![db_0or1row get_file_id " - select content_item.get_live_revision(content_item.get_id(:path,file_storage.get_root_folder([ad_conn package_id]))) as version_id from dual"] { - ad_script_abort - } -} - ad_require_permission $version_id "read" +#set indb_p [ad_parameter "StoreFilesInDatabaseP" -package_id [ad_conn package_id]] +# We get the storage type from the way CR stored the file, instead of +# querying the package instance parameter. With this, we still are able +# to offer download of the file even if the site-admin mistakenly +# changes the storage type parameter after files are already stored in CR db_1row file_type " -select mime_type +select mime_type,(case when lob is null then 0 + else 1 + end) as indb_p from cr_revisions where revision_id = :version_id" ReturnHeaders $mime_type -db_write_blob version_write "select content - from cr_revisions - where revision_id = $version_id" +if {$indb_p} { + db_write_blob version_write_blob "select content + from cr_revisions + where revision_id = $version_id" +} else { + + # JS: I promise to make this cleaner... + set storage_type "file" + + db_write_blob version_write_file " + select '[cr_fs_path]' || filename as content + from cr_revisions + where revision_id = $version_id" +} + + +