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 -N -r1.1.4.1 -r1.1.4.2 --- openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl 27 Sep 2002 15:02:06 -0000 1.1.4.1 +++ openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl 6 Dec 2002 12:40:22 -0000 1.1.4.2 @@ -5,27 +5,36 @@ # # Walter McGinnis (wtem@olywa.net), 2001-09-23 # based on original photo-album package code by Tom Baginski +# +# JCD 2002-12-96 This should be fixed since on oracle anyway, being in a +# transaction does not mean that you get read level consistency across +# queries. End result is that someone can do an insert into the +# delete list and the delete_files query will whack it and the file +# will then never be deleted. Oops. + ad_proc -private cr_delete_scheduled_files {} { - 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. + 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 concurrancy checks to make sure another - version of the proc is running/deleting a file. - Will add some concurancy checks to a future revision. - Right now go with short and sweet, count on scheduling to prevent conflicts + + This proc is extremely simple, and does not have any concurrancy + checks to make sure another version of the proc is + running/deleting a file. Will add some concurancy checks to a + 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 "" { + 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" ns_unlink -nocomplain "$file" - } - # now that all scheduled files deleted, clear table - db_dml delete_files "" + } + # now that all scheduled files deleted, clear table + db_dml delete_files { *SQL* } } } Index: openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.xql,v diff -u -N -r1.1.4.1 -r1.1.4.2 --- openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.xql 27 Sep 2002 15:02:06 -0000 1.1.4.1 +++ openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.xql 6 Dec 2002 12:40:22 -0000 1.1.4.2 @@ -1,6 +1,16 @@ + + + SELECT distinct crftd.path as storage_area_key + FROM cr_files_to_delete crftd + WHERE not exists (SELECT 1 + FROM cr_revisions r + WHERE r.content = crftd.path) + + + delete from cr_files_to_delete