Index: openacs-4/packages/acs-content-repository/acs-content-repository.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/acs-content-repository.info,v diff -u -r1.13 -r1.14 --- openacs-4/packages/acs-content-repository/acs-content-repository.info 17 Sep 2001 05:16:40 -0000 1.13 +++ openacs-4/packages/acs-content-repository/acs-content-repository.info 27 Sep 2001 22:48:16 -0000 1.14 @@ -20,6 +20,7 @@ + Index: openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql 12 May 2001 05:09:48 -0000 1.3 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-create.sql 27 Sep 2001 22:48:16 -0000 1.4 @@ -158,34 +158,35 @@ -- Define the cr_items table create table cr_items ( - item_id integer - constraint cr_items_item_id_fk references - acs_objects on delete cascade - constraint cr_items_pk primary key, - parent_id integer - constraint cr_items_parent_id_nil - not null - constraint cr_items_parent_id_fk references - acs_objects on delete cascade, - name varchar2(400) - constraint cr_items_name_nil - not null, - locale varchar2(4) - constraint cr_items_locale_fk references - cr_locales, - live_revision integer, - latest_revision integer, - publish_status varchar2(40) - constraint cr_items_pub_status_chk - check (publish_status in - ('production', 'ready', 'live', 'expired') - ), - content_type varchar2(100) - constraint cr_items_rev_type_fk - references acs_object_types, - storage_type varchar2(10) default 'lob' not null - constraint cr_revisions_storage_type - check (storage_type in ('lob','file')) + item_id integer + constraint cr_items_item_id_fk references + acs_objects on delete cascade + constraint cr_items_pk primary key, + parent_id integer + constraint cr_items_parent_id_nil + not null + constraint cr_items_parent_id_fk references + acs_objects on delete cascade, + name varchar2(400) + constraint cr_items_name_nil + not null, + locale varchar2(4) + constraint cr_items_locale_fk references + cr_locales, + live_revision integer, + latest_revision integer, + publish_status varchar2(40) + constraint cr_items_pub_status_chk + check (publish_status in + ('production', 'ready', 'live', 'expired') + ), + content_type varchar2(100) + constraint cr_items_rev_type_fk + references acs_object_types, + storage_type varchar2(10) default 'lob' not null + constraint cr_revisions_storage_type + check (storage_type in ('lob','file')), + storage_area_key varchar2(100) default 'CR_FILES' not null ); create index cr_items_by_locale on cr_items(locale); @@ -208,6 +209,19 @@ If null, then no revisions should be allowed. '; +-- content-create.sql patch +-- +-- adds standard mechanism for deleting revisions from the file-system +-- +-- Walter McGinnis (wtem@olywa.net), 2001-09-23 +-- based on original photo-album package code by Tom Baginski +-- + +create table cr_files_to_delete ( + path varchar2(250), + storage_area_key varchar2(100) +); + create table cr_child_rels ( rel_id integer constraint cr_child_rels_rel_pk @@ -342,6 +356,25 @@ 4000 character limit. '; + +-- (DanW - OpenACS) Added cleanup trigger to log file items that need +-- to be cleaned up from the CR. + +create or replace trigger cr_cleanup_cr_files_del_trg +before delete on cr_revisions +for each row +begin + insert into cr_files_to_delete + select r.content as path, i.storage_area_key + from cr_items i, cr_revisions r + where i.item_id = r.item_id + and r.revision_id = :old.revision_id + and i.storage_type = 'file'; + +end; +/ +show errors + -------------------------------------------------------------- -- CONTENT PUBLISHING -------------------------------------------------------------- Index: openacs-4/packages/acs-content-repository/sql/oracle/content-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-content-repository/sql/oracle/content-drop.sql 24 Mar 2001 22:00:48 -0000 1.1 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-drop.sql 27 Sep 2001 22:48:16 -0000 1.2 @@ -173,6 +173,7 @@ drop table cr_item_publish_audit; -- content revisions +drop table cr_files_to_delete; drop table cr_content_text; drop table cr_revision_attributes; drop table cr_revisions cascade constraints; Index: openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 24 Mar 2001 22:00:48 -0000 1.1 +++ openacs-4/packages/acs-content-repository/sql/oracle/content-image.sql 27 Sep 2001 22:48:16 -0000 1.2 @@ -88,3 +88,192 @@ end; / show errors + + +-- content-image.sql patch +-- +-- adds standard image pl/sql package +-- +-- Walter McGinnis (wtem@olywa.net), 2001-09-23 +-- based on original photo-album package code by Tom Baginski +-- + +create or replace package image +as + --/** + -- Creates a new image + -- Binary file stored in file-system + --*/ + function new ( + name in cr_items.name%TYPE, + parent_id in cr_items.parent_id%TYPE default null, + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_id%TYPE default null, + content_type in acs_object_types.object_type%TYPE default 'image', + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null, + locale in cr_items.locale%TYPE default null, + context_id in acs_objects.context_id%TYPE default null, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + relation_tag in cr_child_rels.relation_tag%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + path in images.path%TYPE, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in images.file_size%TYPE default null + ) return cr_items.item_id%TYPE; + + --/** + -- Deletes a single revision of image + -- Schedules binary file for deletion. + -- File delete sweep checks to see if no other images are using binary prior to deleting + --*/ + procedure delete_revision ( + revision_id in cr_revisions.revision_id%TYPE + ); + + --/** + -- Deletes a image and all revisions + -- Schedules binary files for deletion. + -- + -- Be careful, cannot be undone (easily) + --*/ + procedure delete ( + item_id in cr_items.item_id%TYPE + ); + +end image; +/ +show errors; + +create or replace package body image +as + function new ( + name in cr_items.name%TYPE, + parent_id in cr_items.parent_id%TYPE default null, + item_id in acs_objects.object_id%TYPE default null, + revision_id in acs_objects.object_id%TYPE default null, + content_type in acs_object_types.object_type%TYPE default 'image', + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null, + locale in cr_items.locale%TYPE default null, + context_id in acs_objects.context_id%TYPE default null, + title in cr_revisions.title%TYPE default null, + description in cr_revisions.description%TYPE default null, + mime_type in cr_revisions.mime_type%TYPE default null, + nls_language in cr_revisions.nls_language%TYPE default null, + relation_tag in cr_child_rels.relation_tag%TYPE default null, + is_live in char default 'f', + publish_date in cr_revisions.publish_date%TYPE default sysdate, + path in images.path%TYPE, + height in images.height%TYPE default null, + width in images.width%TYPE default null, + file_size in images.file_size%TYPE default null + ) return cr_items.item_id%TYPE + is + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + begin + + v_item_id := content_item.new ( + name => name, + item_id => item_id, + parent_id => parent_id, + relation_tag => relation_tag, + content_type => content_type, + creation_date => sysdate, + creation_user => creation_user, + creation_ip => creation_ip, + locale => locale, + context_id => context_id, + storage_type => 'file' + ); + + v_revision_id := content_revision.new ( + title => title, + description => description, + item_id => v_item_id, + revision_id => revision_id, + publish_date => publish_date, + mime_type => mime_type, + nls_language => nls_language, + creation_date => sysdate, + creation_user => creation_user, + creation_ip => creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, height, width); + + -- update revision with image file info + update cr_revisions + set content_length = file_size, + content = path + where revision_id = v_revision_id; + + -- is_live => 't' not used as part of content_item.new + -- because content_item.new does not let developer specify revision_id, + -- revision_id is determined in advance + + if is_live = 't' then + content_item.set_live_revision ( + revision_id => v_revision_id + ); + end if; + + return v_item_id; + end new; + + procedure delete_revision ( + revision_id in cr_revisions.revision_id%TYPE + ) + is + begin + insert into cr_files_to_delete (path) + select path from images where image_id = image.delete_revision.revision_id; + + content_revision.delete ( + revision_id => revision_id + ); + end delete_revision; + + procedure delete ( + item_id in cr_items.item_id%TYPE + ) + is + + cursor image_revision_cur is + select + revision_id + from + cr_revisions + where + item_id = image.delete.item_id + order by revision_id asc; + + -- order by used in cursur so latest revision will be deleted last + -- save resetting latest revision multiple times during delete process + + begin + for v_revision_val in image_revision_cur loop + image.delete_revision ( + revision_id => v_revision_val.revision_id + ); + end loop; + + content_item.delete ( + item_id => item_id + ); + end delete; + +end image; +/ +show errors; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql,v diff -u -r1.26 -r1.27 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 17 Sep 2001 05:16:40 -0000 1.26 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-create.sql 27 Sep 2001 22:48:16 -0000 1.27 @@ -166,35 +166,36 @@ -- Define the cr_items table create table cr_items ( - item_id integer - constraint cr_items_item_id_fk references - acs_objects on delete cascade - constraint cr_items_pk primary key, - parent_id integer - constraint cr_items_parent_id_nil - not null - constraint cr_items_parent_id_fk references - acs_objects on delete cascade, - name varchar(400) - constraint cr_items_name_nil - not null, - locale varchar(4) - constraint cr_items_locale_fk references - cr_locales, - live_revision integer, - latest_revision integer, - publish_status varchar(40) - constraint cr_items_pub_status_chk - check (publish_status in - ('production', 'ready', 'live', 'expired') - ), - content_type varchar(100) - constraint cr_items_rev_type_fk - references acs_object_types, - storage_type varchar(10) default 'text' not null - constraint cr_items_storage_type - check (storage_type in ('lob','text','file')), - tree_sortkey varchar(4000) + item_id integer + constraint cr_items_item_id_fk references + acs_objects on delete cascade + constraint cr_items_pk primary key, + parent_id integer + constraint cr_items_parent_id_nil + not null + constraint cr_items_parent_id_fk references + acs_objects on delete cascade, + name varchar(400) + constraint cr_items_name_nil + not null, + locale varchar(4) + constraint cr_items_locale_fk references + cr_locales, + live_revision integer, + latest_revision integer, + publish_status varchar(40) + constraint cr_items_pub_status_chk + check (publish_status in + ('production', 'ready', 'live', 'expired') + ), + content_type varchar(100) + constraint cr_items_rev_type_fk + references acs_object_types, + storage_type varchar(10) default 'text' not null + constraint cr_items_storage_type + check (storage_type in ('lob','text','file')), + storage_area_key varchar(100) default 'CR_FILES' not null, + tree_sortkey varchar(4000) ); create index cr_items_by_locale on cr_items(locale); @@ -205,6 +206,28 @@ create unique index cr_items_unique_id on cr_items(parent_id, item_id); create index cr_items_by_parent_id on cr_items(parent_id); +-- content-create.sql patch +-- +-- adds standard mechanism for deleting revisions from the file-system +-- +-- Walter McGinnis (wtem@olywa.net), 2001-09-23 +-- based on original photo-album package code by Tom Baginski +-- + +create table cr_files_to_delete ( + path varchar(250), + storage_area_key varchar(100) +); + +comment on table cr_files_to_delete is ' + Table to store files to be deleted by a scheduled sweep. + Since binaries are stored in filesystem and attributes in database, + need a way to delete both atomically. So any process to delete file-system cr_revisions, + copies the file path to this table as part of the delete transaction. Sweep + run later to remove the files from filesystem once database info is successfully deleted. +'; + + -- DCW, this can't be defined in the apm_package_versions table defintion, -- because cr_items is created afterwards. @@ -575,7 +598,28 @@ after delete on cr_revisions for each row execute procedure cr_revision_del_rev_ri_trg(); +-- (DanW - OpenACS) Added cleanup trigger to log file items that need +-- to be cleaned up from the CR. +create function cr_cleanup_cr_files_del_trg() returns opaque as ' +declare + +begin + insert into cr_files_to_delete + select r.content as path, i.storage_area_key + from cr_items i, cr_revisions r + where i.item_id = r.item_id + and r.revision_id = old.revision_id + and i.storage_type = ''file''; + + return old; +end;' language 'plpgsql'; + +create trigger cr_cleanup_cr_files_del_trg +before delete on cr_revisions +for each row execute procedure cr_cleanup_cr_files_del_trg(); + + create table cr_revision_attributes ( revision_id integer constraint cr_revision_attributes_pk Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql 7 Sep 2001 23:48:47 -0000 1.3 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-drop.sql 27 Sep 2001 22:48:16 -0000 1.4 @@ -186,6 +186,7 @@ drop table cr_item_publish_audit; -- content revisions +drop table cr_files_to_delete; drop table cr_content_text; drop table cr_revision_attributes; drop table cr_revisions cascade constraints; Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql 27 Mar 2001 02:02:31 -0000 1.1 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image-drop.sql 27 Sep 2001 22:48:16 -0000 1.2 @@ -9,6 +9,11 @@ -- http://www.fsf.org/copyleft/gpl.html -- unregister mime types from the image type + +drop function image__delete (integer); + +drop function image__new (varchar,integer,integer,integer,varchar,integer,varchar,integer,varchar,varchar,boolean,timestamp,varchar,integer,integer,integer); + begin; select content_type__unregister_mime_type( Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 30 Mar 2001 05:31:33 -0000 1.2 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-image.sql 27 Sep 2001 22:48:16 -0000 1.3 @@ -89,3 +89,135 @@ ); end; + + +-- content-image.sql patch +-- +-- adds standard image pl/sql package +-- +-- Walter McGinnis (wtem@olywa.net), 2001-09-23 +-- based on original photo-album package code by Tom Baginski +-- + +/* + Creates a new image + Binary file stored in file-system +*/ + +create function image__new (varchar,integer,integer,integer,varchar,integer,varchar,varchar,varchar,varchar,boolean,timestamp,varchar,integer,integer,integer + ) returns integer as ' + declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__item_id alias for $3; -- default null + new__revision_id alias for $4; -- default null + new__mime_type alias for $5; -- default jpeg + new__creation_user alias for $6; -- default null + new__creation_ip alias for $7; -- default null + new__relation_tag alias for $8; -- default null + new__title alias for $9; -- default null + new__description alias for $10; -- default null + new__is_live alias for $11; -- default f + new__publish_date alias for $12; -- default now() + new__path alias for $13; + new__file_size alias for $14; + new__height alias for $15; + new__width alias for $16; + + new__locale varchar default null; + new__nls_language varchar default null; + new__creation_date timestamp default now(); + new__context_id integer; + + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + begin + new__context_id := new__parent_id; + + v_item_id := content_item__new ( + new__name, + new__parent_id, + new__item_id, + new__locale, + new__creation_date, + new__creation_user, + new__context_id, + new__creation_ip, + ''content_item'', + ''image'', + new__title, + new__description, + new__mime_type, + new__nls_language, + null, + ''file'' -- storage_type + ); + + -- update cr_child_rels to have the correct relation_tag + update cr_child_rels + set relation_tag = new__relation_tag + where parent_id = new__parent_id + and child_id = new__item_id + and relation_tag = content_item__get_content_type(new__parent_id) || ''-'' || ''image''; + + v_revision_id := content_revision__new ( + new__title, + new__description, + new__publish_date, + new__mime_type, + new__nls_language, + null, + v_item_id, + new__revision_id, + new__creation_date, + new__creation_user, + new__creation_ip + ); + + insert into images + (image_id, height, width) + values + (v_revision_id, new__height, new__width); + + -- update revision with image file info + update cr_revisions + set content_length = new__file_size, + content = new__path + where revision_id = v_revision_id; + + -- is_live => ''t'' not used as part of content_item.new + -- because content_item.new does not let developer specify revision_id, + -- revision_id is determined in advance + + if new__is_live = ''t'' then + PERFORM content_item__set_live_revision (v_revision_id); + end if; + + return v_item_id; +end; ' language 'plpgsql'; + +create function image__delete (integer) +returns integer as ' +declare + v_item_id alias $1; + v_revision_id integer; + -- order by used in cursur so latest revision will be deleted last + -- save resetting latest revision multiple times during delete process +begin + for v_revision_id in select + revision_id + from + cr_revisions + where + item_id = v_item_id + order by revision_id asc + loop + PERFORM content_revision__delete_revision ( + v_revision_id + ); + end loop; + + PERFORM content_item__delete (v_item_id); + return 1; +end; ' language 'plpgsql'; + Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql,v diff -u -r1.30 -r1.31 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 5 Sep 2001 00:09:52 -0000 1.30 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-item.sql 27 Sep 2001 22:48:16 -0000 1.31 @@ -425,6 +425,167 @@ -- function new -- sets security_inherit_p to FALSE -DaveB +create function content_item__new ( integer, varchar, integer, varchar, timestamp, integer, integer, varchar, boolean, varchar, text, varchar, boolean, varchar) + +returns integer as ' +declare + new__item_id alias for $1; --default null + new__name alias for $2; + new__parent_id alias for $3; -- default null + new__title alias for $4; -- default null + new__creation_date alias for $5; -- default now() + new__creation_user alias for $6; -- default null + new__context_id alias for $7; -- default null + new__creation_ip alias for $8; -- default null + new__is_live alias for $9; -- default ''f'' + new__mime_type alias for $10; + new__text alias for $11; -- default null + new__storage_type alias for $12; -- check in (''text'', ''file'') + new__security_inherit_p alias for $13; -- default ''t'' + new__storage_area_key alias for $14; -- default ''CR_FILES'' + new__item_subtype varchar default ''content_item''; + new__content_type varchar default ''content_revision''; + new__description varchar default null; + new__relation_tag varchar default null; + new__nls_language varchar default null; + v_parent_id cr_items.parent_id%TYPE; + v_parent_type acs_objects.object_type%TYPE; + v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; + v_title cr_revisions.title%TYPE; + v_rel_id acs_objects.object_id%TYPE; + v_rel_tag cr_child_rels.relation_tag%TYPE; + v_context_id acs_objects.context_id%TYPE; +begin + + -- place the item in the context of the pages folder if no + -- context specified + + if new__parent_id is null then + v_parent_id := content_item_globals.c_root_folder_id; + else + v_parent_id := new__parent_id; + end if; + + -- Determine context_id + if new__context_id is null then + v_context_id := v_parent_id; + else + v_context_id := new__context_id; + end if; + + if v_parent_id = 0 or + content_folder__is_folder(v_parent_id) = ''t'' then + + if v_parent_id != 0 and + content_folder__is_registered( + v_parent_id, new__content_type, ''f'') = ''f'' then + + raise EXCEPTION ''-20000: This item\\\'s content type % is not registered to this folder %'', new__content_type, v_parent_id; + end if; + + else if v_parent_id != 0 then + + select object_type into v_parent_type from acs_objects + where object_id = v_parent_id; + + if NOT FOUND then + raise EXCEPTION ''-20000: Invalid parent ID % specified in content_item.new'', v_parent_id; + end if; + + if content_item__is_subclass(v_parent_type, ''content_item'') = ''t'' and + content_item__is_valid_child(v_parent_id, new__content_type) = ''f'' then + + raise EXCEPTION ''-20000: This item\\\'s content type % is not allowed in this container %'', new__content_type, v_parent_id; + end if; + + end if; end if; + + + -- Create the object + + v_item_id := acs_object__new( + new__item_id, + new__item_subtype, + new__creation_date, + new__creation_user, + new__creation_ip, + v_context_id, + new__security_inherit_p + ); + + insert into cr_items ( + item_id, name, content_type, parent_id, storage_type, storage_area_key + ) values ( + v_item_id, new__name, new__content_type, v_parent_id, new__storage_type, + new__storage_area_key + ); + + -- if the parent is not a folder, insert into cr_child_rels + if v_parent_id != 0 and + content_folder__is_folder(v_parent_id) = ''f'' and + content_item__is_valid_child(v_parent_id, new__content_type) = ''t'' then + + v_rel_id := acs_object__new( + null, + ''cr_item_child_rel'', + now(), + null, + null, + v_parent_id, + ''f'' + ); + + if new__relation_tag is null then + v_rel_tag := content_item__get_content_type(v_parent_id) + || ''-'' || new__content_type; + else + v_rel_tag := new__relation_tag; + end if; + + insert into cr_child_rels ( + rel_id, parent_id, child_id, relation_tag, order_n + ) values ( + v_rel_id, v_parent_id, v_item_id, v_rel_tag, v_item_id + ); + + end if; + + -- use the name of the item if no title is supplied + if new__title is null then + v_title := new__name; + else + v_title := new__title; + end if; + + if new__title is not null or + new__text is not null then + + v_revision_id := content_revision__new( + v_title, + new__description, + now(), + new__mime_type, + null, + new__text, + v_item_id, + null, + new__creation_date, + new__creation_user, + new__creation_ip + ); + + end if; + + -- make the revision live if is_live is true + if new__is_live = ''t'' then + PERFORM content_item__set_live_revision(v_revision_id); + end if; + + return v_item_id; + +end;' language 'plpgsql'; + create function content_item__new ( integer, varchar, integer, varchar, timestamp, integer, integer, varchar, boolean, varchar, text, varchar, boolean) returns integer as ' Index: openacs-4/packages/acs-content-repository/tcl/acs-content-repository-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/acs-content-repository-init.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-content-repository/tcl/acs-content-repository-init.tcl 26 Sep 2001 12:09:27 -0000 1.3 +++ openacs-4/packages/acs-content-repository/tcl/acs-content-repository-init.tcl 27 Sep 2001 22:48:16 -0000 1.4 @@ -1,5 +1,14 @@ template::filter add content::init +# a patch to the cr for handling the deleting revision's files +# when the revision has been deleted from the database +# schedules the sweep +# +# Walter McGinnis (wtem@olywa.net), 2001-09-23 +# based on original photo-album package code by Tom Baginski + +ad_schedule_proc -thread t 86400 cr_delete_scheduled_files + ad_proc -public acs_cr_scheduled_release_exec {} { This was handled by oracle, but since other dbs, such as postgresql don't 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.tcl 27 Sep 2001 22:48:16 -0000 1.1 @@ -0,0 +1,37 @@ +# tcl/acs-content-repository-procs.tcl patch +# +# a patch to the cr for handling the deleting revision's files +# when the revision has been deleted from the database +# +# Walter McGinnis (wtem@olywa.net), 2001-09-23 +# based on original photo-album package code by Tom Baginski + +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. + 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 +} { + db_transaction { + # subselect makes sure there isn't a parent revision still lying around + db_foreach fetch_paths { + + select distinct crftd.path storage_area_key + from cr_files_to_delete crftd + and not exists (select 1 + from cr_revisions r + where r.content = crftd.path) + } { + # 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 "delete from cr_files_to_delete" + } +} + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/tcl/acs-content-repository-procs.xql 27 Sep 2001 22:48:16 -0000 1.1 @@ -0,0 +1,19 @@ + + + + + + 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.content = crftd.path) + + + + + + + delete from cr_files_to_delete + + + +