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.11.2.1 -r1.11.2.2 --- openacs-4/packages/static-pages/tcl/static-pages-procs.tcl 4 Dec 2002 22:10:24 -0000 1.11.2.1 +++ openacs-4/packages/static-pages/tcl/static-pages-procs.tcl 11 Dec 2002 21:55:32 -0000 1.11.2.2 @@ -12,8 +12,10 @@ -file_add_proc "" -file_change_proc "" -file_unchanged_proc "" + -file_read_error_proc "" -folder_add_proc "" -folder_unchanged_proc "" + -stack_depth 1 } fs_root root_folder_id @@ -54,6 +56,8 @@ @author Brandoch Calef (bcalef@arsdigita.com) @creation-date 2001-02-07 } { + set proc_name {sp_sync_cr_with_filesystem} + set sync_session_id [db_nextval sp_session_id_seq] set fs_trimmed [string trimright $fs_root "/"] @@ -111,6 +115,7 @@ # install dir, this is what gets inserted into the db - DaveB set sp_filename [sp_get_relative_file_path $file] 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 @@ -120,8 +125,19 @@ set file_from_fs [read $fp] close $fp } errmsg]} { - ad_return_error "Error reading file" \ - "This error was encountered while reading $file: $errmsg" + # Log and return an appropriate message, then + # continue on trying to process the other files. + # We do NOT want to abort the whole scan just + # because one file had problems: + # --atp@piskorski.com, 2002/09/12 16:49 EDT + + set mesg "$proc_name: Error reading file: '$file': [ns_quotehtml $errmsg]" + ns_log Error $mesg + if { ![empty_string_p $file_read_error_proc] } { + ns_log Notice "$proc_name: about to run file_read_error_proc:" + uplevel 1 [list $file_read_error_proc $file $static_page_id $mesg] + } + continue } set file_updated 0 @@ -172,16 +188,30 @@ values (:sync_session_id,:static_page_id) } } else { + # The file is NOT in the db yet at all: + # Try to extract a title: if { [catch { set fp [open $file r] set file_contents [read $fp] close $fp } errmsg]} { - ad_return_error "Error reading file" \ - "This error was encountered while reading $file: $errmsg" + # Log and return an appropriate message, then + # continue on trying to process the other files. + # We do NOT want to abort the whole scan just + # because one file had problems: + # --atp@piskorski.com, 2002/09/12 16:49 EDT + + set mesg "$proc_name: Error reading file: '$file': [ns_quotehtml $errmsg]" + ns_log Error $mesg + if { ![empty_string_p $file_read_error_proc] } { + ns_log Notice "$proc_name: about to run file_read_error_proc:" + uplevel 1 [list $file_read_error_proc $file $static_page_id $mesg] + } + continue } + # TODO: This is very HTML specific: --atp@piskorski.com, 2001/08/13 21:58 EDT if { ![regexp -nocase {
$path
: unchanged"
+ ns_write "\n$path
: unchanged"
}
proc sp_new_item { path id } {
- upvar file_items file_items
- ns_write "$path
: added"
+ ns_write "\n$path
: added"
}
proc sp_changed_item { path id } {
- upvar file_items file_items
- ns_write "$path
: updated"
+ ns_write "\n$path
: updated"
# The title may have changed:
sp_flush_page $id
}
+proc sp_error_item { path id msg } {
+ ns_write "\n$path
: Error:
+$msg" +} + set title "Filesystem search" set context_bar [ad_context_bar $title] @@ -50,6 +53,7 @@ -file_unchanged_proc sp_old_item \ -file_add_proc sp_new_item \ -file_change_proc sp_changed_item \ + -file_read_error_proc sp_error_item \ -folder_add_proc sp_new_item \ -folder_unchanged_proc sp_old_item \ "[acs_root_dir]/www" $root_folder_id