cr_delete_scheduled_files (private)
cr_delete_scheduled_files
Defined in packages/acs-content-repository/tcl/acs-content-repository-procs.tcl
Tries to delete all the files in cr_files_to_delete. Makes sure file isn't being used by another revision prior to deleting it. Should be scheduled daily. This proc is extremely simple, and does not have any concurrency checks to make sure another version of the proc is running/deleting a file. Will add some concurrency checks to a future revision. Right now go with short and sweet, count on scheduling to prevent conflicts
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: db_transaction { # subselect makes sure there isn't a parent revision still lying around db_foreach fetch_paths {} { set file [cr_fs_path $storage_area_key]/$path if {[regexp {^[0-9/]+$} $path]} { # the filename looks valid, delete the file from filesystem ns_log Debug "cr_delete_scheduled_files: deleting $file" file delete -- $file } else { ns_log Warning "cr_delete_scheduled_files: refuse to delete $file" } } # now that all scheduled files deleted, clear table db_dml delete_files {} } # # cleanup orphaned files (leftovers from aborted transactions) # cr_cleanup_orphaned_filesGeneric XQL file: <fullquery name="cr_delete_scheduled_files.delete_files"> <querytext> delete from cr_files_to_delete </querytext> </fullquery>packages/acs-content-repository/tcl/acs-content-repository-procs.xql
PostgreSQL XQL file: <fullquery name="cr_delete_scheduled_files.fetch_paths"> <querytext> SELECT distinct crftd.path, crftd.storage_area_key FROM cr_files_to_delete crftd WHERE not exists ( SELECT 1 FROM cr_revisions r WHERE substring(r.content for 100) = substring(crftd.path for 100) ) </querytext> </fullquery>packages/acs-content-repository/tcl/acs-content-repository-procs-postgresql.xql
Oracle XQL file: <fullquery name="cr_delete_scheduled_files.fetch_paths"> <querytext> select distinct crftd.path, crftd.storage_area_key from cr_files_to_delete crftd where not exists (select 1 from cr_revisions r where r.filename = crftd.path) </querytext> </fullquery>packages/acs-content-repository/tcl/acs-content-repository-procs-oracle.xql