cr_check_orphaned_files (private)

 cr_check_orphaned_files [ -delete ] [ -mtime mtime ]

Defined in packages/acs-content-repository/tcl/acs-content-repository-procs.tcl

Check for orphaned files in the content repository 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 maintenance 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.

Switches:
-delete
(boolean) (optional)
delete the orphaned files
-mtime
(optional)
same semantics as mtime in the file command
Author:
gustaf.neumann@wu-wien.ac.at

Partial Call Graph (max 5 caller/called nodes):
%3 cr_count_file_entries cr_count_file_entries (private) cr_check_orphaned_files cr_check_orphaned_files cr_check_orphaned_files->cr_count_file_entries

Testcases:
No testcase defined.
Source code:
    set cr_root [nsv_get CR_LOCATIONS CR_FILES]
    set root_length [string length $cr_root]
    set result ""

    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

        # For every file in the content repository 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
        }
    }

    return $result
Generic XQL file:
packages/acs-content-repository/tcl/acs-content-repository-procs.xql

PostgreSQL XQL file:
packages/acs-content-repository/tcl/acs-content-repository-procs-postgresql.xql

Oracle XQL file:
packages/acs-content-repository/tcl/acs-content-repository-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: