Index: openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl,v diff -u -r1.7.2.4 -r1.7.2.5 --- openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl 31 Dec 2013 16:21:10 -0000 1.7.2.4 +++ openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl 9 May 2014 08:25:45 -0000 1.7.2.5 @@ -24,17 +24,21 @@ future revision. Right now go with short and sweet, count on scheduling to prevent conflicts } { - db_transaction { - # subselect makes sure there isn't a parent revision still lying around - db_foreach fetch_paths { *SQL* } { + db_transaction { + # subselect makes sure there isn't a parent revision still lying around + db_foreach fetch_paths { *SQL* } { - # try to remove file from filesystem - set file [cr_fs_path $storage_area_key]/$path - ns_log Debug "cr_delete_scheduled_files: deleting $file" - file delete $file - } - # now that all scheduled files deleted, clear table - db_dml delete_files { *SQL* } + set file [cr_fs_path $storage_area_key]/$path + if {$path eq ""} { + ns_log Warning "cr_delete_scheduled_files: refuse to delete $file" + } else { + # remove the file from filesystem + ns_log Debug "cr_delete_scheduled_files: deleting $file" + file delete $file + } + } + # now that all scheduled files deleted, clear table + db_dml delete_files { *SQL* } } # @@ -83,18 +87,18 @@ ad_proc cr_check_orphaned_files {-delete:boolean {-mtime ""}} { - Check for orphaned files in the content respository directory, and - delete such files if required. Orphaned files might be created, - when files are added to the content repository, but the transaction - is being aborted. This function is intended to be used for one-time - maintainenace operations. Starting with 5.8.1, OpenACS contains - support for handling orphaned files much more efficiently via a - transaction log that is checked via cr_cleanup_orphaned_files in - cr_delete_scheduled_files. + Check for orphaned files in the content respository directory, and + delete such files if required. Orphaned files might be created, + when files are added to the content repository, but the transaction + is being aborted. This function is intended to be used for one-time + maintainenace operations. Starting with 5.8.1, OpenACS contains + support for handling orphaned files much more efficiently via a + transaction log that is checked via cr_cleanup_orphaned_files in + cr_delete_scheduled_files. - @param -delete delete the orphaned files - @param -mtime same semantics as mtime in the file command - + @param -delete delete the orphaned files + @param -mtime same semantics as mtime in the file command + } { set cr_root [nsv_get CR_LOCATIONS CR_FILES] set root_length [string length $cr_root] @@ -103,20 +107,27 @@ set cmd [list exec find $cr_root/ -type f] if {$mtime ne ""} {lappend cmd -mtime $mtime} foreach f [split [{*}$cmd] \n] { - set name [string range $f $root_length end] - if {![regexp {^[0-9/]+$} $name]} continue + set name [string range $f $root_length end] + if {![regexp {^[0-9/]+$} $name]} continue - # For every file in the content respository directory, check if this - # file is still referenced from the content-revisions. + # For every file in the content respository directory, check if this + # file is still referenced from the content-revisions. - set x [cr_count_file_entries $name] - if {$x > 0} continue - - lappend result $f - if {$delete_p} { - file delete $f - } + set x [cr_count_file_entries $name] + if {$x > 0} continue + + lappend result $f + if {$delete_p} { + file delete $f + } } return $result } + +# +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: