Index: openacs-4/packages/static-pages/sql/postgresql/static-pages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/postgresql/static-pages-create.sql,v diff -u -r1.15 -r1.16 --- openacs-4/packages/static-pages/sql/postgresql/static-pages-create.sql 31 Oct 2001 17:47:55 -0000 1.15 +++ openacs-4/packages/static-pages/sql/postgresql/static-pages-create.sql 3 Dec 2001 16:58:46 -0000 1.16 @@ -156,7 +156,8 @@ references sp_folders, show_comments_p boolean default 't' - not null + not null, + mtime integer ); comment on table static_pages is ' Extends the cr_items table to hold information on static pages. @@ -171,6 +172,9 @@ Are comments shown on the page, or is the user simply offered a link to view the comments? '; +comment on column static_pages.mtime is ' + Last modification time of file as reported by [file mtime] +'; -- Another foreign key column: -- @@ -268,8 +272,9 @@ -- default null, varchar, -- creation_ip in acs_objects.creation_ip%TYPE -- default null, - integer -- context_id in acs_objects.context_id%TYPE + integer, -- context_id in acs_objects.context_id%TYPE -- default null + integer -- mtime ) returns integer as ' declare p_static_page_id alias for $1; @@ -282,6 +287,7 @@ p_creation_user alias for $8; p_creation_ip alias for $9; p_context_id alias for $10; + p_mtime alias for $11; v_item_id static_pages.static_page_id%TYPE; v_permission_row RECORD; @@ -338,12 +344,13 @@ -- Insert row into static_pages: insert into static_pages - (static_page_id, filename, folder_id, show_comments_p) + (static_page_id, filename, folder_id, show_comments_p, mtime) values ( v_item_id, p_filename, p_folder_id, - p_show_comments_p + p_show_comments_p, + p_mtime ); return v_item_id; @@ -353,12 +360,14 @@ integer, -- folder_id in sp_folders.folder_id%TYPE, varchar, -- filename in static_pages.filename%TYPE default null, - varchar -- title in cr_revisions.title%TYPE default null + varchar, -- title in cr_revisions.title%TYPE default null + integer -- mtime ) returns integer as ' declare p_folder_id alias for $1; p_filename alias for $2; p_title alias for $3; + p_mtime alias for $4; v_static_page_id static_pages.static_page_id%TYPE; v_item_id static_pages.static_page_id%TYPE; @@ -374,7 +383,8 @@ now(), -- creation_date NULL, -- creation_user NULL, -- creation_ip - NULL -- conext_id + NULL, -- conext_id + p_mtime -- mtime ); end;' language 'plpgsql'; @@ -839,6 +849,8 @@ return v_show_comments_p; end;' language 'plpgsql'; + +\i static-pages-sc-create.sql -- end static_page; Index: openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql 1 Nov 2001 19:17:16 -0000 1.6 +++ openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql 3 Dec 2001 16:58:46 -0000 1.7 @@ -29,7 +29,15 @@ + + + select static_page_id from static_pages + where filename = :sp_filename + + + + Index: openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql,v diff -u -r1.12 -r1.13 --- openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql 1 Nov 2001 19:17:16 -0000 1.12 +++ openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql 3 Dec 2001 16:58:46 -0000 1.13 @@ -41,20 +41,30 @@ - update cr_revisions set content = :sp_filename where revision_id = content_item__get_live_revisions(:static_page_id) + +end; - + + + + select static_page_id, mtime as mtime_from_db from static_pages + where filename = :sp_filename + + + + select static_page__new( :parent_folder_id, -- folder_id :sp_filename, -- filename - :page_title -- title + :page_title, -- title + :mtime_from_fs -- mtime ); @@ -155,4 +165,5 @@ + Index: openacs-4/packages/static-pages/tcl/static-pages-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/static-pages/tcl/static-pages-procs.tcl 1 Nov 2001 19:37:07 -0000 1.7 +++ openacs-4/packages/static-pages/tcl/static-pages-procs.tcl 3 Dec 2001 16:58:46 -0000 1.8 @@ -118,30 +118,55 @@ # set sp_filename to the file path relative to the OpenACS # install dir, this is what gets inserted into the db - DaveB set sp_filename [sp_get_relative_file_path $file] - - - if [db_0or1row check_db_for_page { - select static_page_id from static_pages + set mtime_from_fs [file mtime $file] + if [db_0or1row check_db_for_page { + select static_page_id, mtime as mtime_from_db from static_pages where filename = :sp_filename }] { - db_1row get_db_page { - select content as file_from_db from cr_revisions - where revision_id = content_item.get_live_revision(:static_page_id) - } - if { [catch { + if { [catch { set fp [open $file r] set file_from_fs [read $fp] close $fp } errmsg]} { ad_return_error "Error reading file" \ "This error was encountered while reading $file: $errmsg" } - if { $file_from_fs != $file_from_db } { + + set file_updated 0 + + set storage_type [db_string get_storage_type ""] + + switch $storage_type { + "file" { + if {$mtime_from_fs != $mtime_from_db} { + set file_updated 1 + } + } + + "lob" { + db_1row get_db_page { + select content as file_from_db from cr_revisions + where revision_id = content_item.get_live_revision(:static_page_id) + } + if {$file_from_db != $file_from_fs} { + set file_updated 1 + } + } + } + + if {$file_updated == 1} { db_dml update_db_file { update cr_revisions set content = empty_blob() where revision_id = content_item.get_live_revision(:static_page_id) returning content into :1 } -blob_files [list $file] + if {$storage_type=="file"} { + + db_dml update_static_page { + update static_pages set mtime = :mtime_from_fs + where static_page_id = :static_page_id + } + } if { [string length $file_change_proc] > 0 } { uplevel "$file_change_proc $file $static_page_id" } Index: openacs-4/packages/static-pages/tcl/static-pages-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/static-pages/tcl/static-pages-procs.xql 23 Oct 2001 18:53:36 -0000 1.6 +++ openacs-4/packages/static-pages/tcl/static-pages-procs.xql 3 Dec 2001 16:58:46 -0000 1.7 @@ -10,18 +10,14 @@ - - - - - select static_page_id from static_pages - where filename = :sp_filename - - + + + select storage_type from cr_items + where item_id = :static_page_id + -