Forum OpenACS Development: Attachment bug

Collapse
Posted by Byron Linares on
Hi all I ran into an error in attachment and I don’t know which would be the correct solution.
When a user tries to attach a file with the same name two times it throws an error at attachment/www/file-add-2

Database operation "dml" failed (exception ERROR, "ERROR: insert or update on table "attachments" violates foreign key constraint "attachments_item_id_fk"
DETAIL: Key (item_id)=(11795) is not present in table "acs_objects".
")

ERROR: insert or update on table "attachments" violates foreign key constraint "attachments_item_id_fk"
DETAIL: Key (item_id)=(11795) is not present in table "acs_objects".

SQL:
insert
into attachments
(object_id, item_id, approved_p)
values
('11794', '11795', 't')

while executing
"ns_pg_bind dml nsdb0 {
insert

This occurs because attachment doesn’t check if a file exists and file storage does
My question is what is the correct solution:
1. Attachment check if a file exist and create a new revision of the file and attach the old file_id
2. Attachment check if a file exists and if it exists creates a new item with a different file name and attaches the new file_id.

Thanks for your comments

Collapse
2: Re: Attachment bug (response to 1)
Posted by Byron Linares on
Hi all, as result of our upgrade processes in Galileo, also I have posted some bug-Enhancement on the openacs bugtracker and the respective patch files

https://openacs.org/bugtracker/openacs/bug?bug%5fnumber=3194

https://openacs.org/bugtracker/openacs/bug?bug%5fnumber=3193

https://openacs.org/bugtracker/openacs/bug?bug%5fnumber=3188

https://openacs.org/bugtracker/openacs/bug?bug%5fnumber=3185

If someone have any comments or suggestions for this matters I’ll be grateful, or I could commit this to CVS HEAD as soon as possible.

and more to come :)

best,
Byron Linares