Forum OpenACS CMS: Re: content repository physical folders keeps growing

Collapse
Posted by Antonio Pisano on
Made some testing: I found out ::fileutil::find cannot retrieve files located into a symlinked directory. In my installation, coming from the new installation scripts, this is unfortunately the case for "content-repository-content-files" and other folders.

Here http://wiki.tcl.tk/776 they say "globfind" command could overcome some limitations of ::fileutil::find and achieve better performance. I was thinking about trying that command instead, but it is not part of the tcl OpenAcs requires right now, so I would need your opinion.

For my current situation, I fixed the proc by using "exec" and the "find" command under linux. It isn't cross-platform, so I will leave it only here for reference.

ad_proc cr_check_orphaned_files {-delete:boolean} {

Check for orphaned files in the content respository directory, and
delete such files if required. Orphaned files might be created, when
files add added to the content repository, but the transaction is being aborted.

@param -delete delete the orphaned files

} {
set cr_root [nsv_get CR_LOCATIONS CR_FILES]
set root_length [string length $cr_root]

# check for missing trailing slash on directory
if {[string index $cr_root end] != "/"} {
append cr_root /
}

set result ""
# get any not-hidden file into cr directory...
foreach f [exec find $cr_root -type f \( ! -iname ".*" \)] {
set name [string range $f $root_length end]
# ...skip names which are not-numerical...
if {![regexp {^[0-9/]+$} $name]} continue
# ...check if we have a revision under this filename...
if {[db_0or1row _ {
select 1 from cr_revisions
where content = :name limit 1}]} continue

# ...otherwise it is an orphan.
lappend result $f

if {$delete_p} {
file delete $f
}
}

return $result
}

All the best

Collapse
Posted by Antonio Pisano on
Ooops... seems like I've messed up a little looking for the last changes to the proc in the cvs browser. You already went for the "find" unix command.

Tried with last version. I saw "find" needs folders to end with "/" to search into them. I added this little check to the proc and committed. Proc seems to work properly.

Bye!