I get an error "The selected file could not be copied, because no file by that name exists." when I create new content with a private file attachment and have a triggered rule that applies changes to the content after saving or updating it. Despite the error message, the file ends up in the correct place in the private directory. I tried to narrow down what exactly causes this error by calling some functions with my triggered rule. The error appears to occur when trying to save the node content (for example, using node_save(&$node)). Could it be that the file paths are not properly set to reflect the private directory when calling node_save?

Comments

keinstein’s picture

As far as I understand you, you change a node after saving it. That results in a second (or more) call to node_save after it has been saved. So the file was already moved from its temporary location to the final location. So in this second call private_upload should not touch the file at all. Or your triggered rule should not call save_node at all.

Are you using the trigger module? Then try to increase the weight of the trigger module above 20 (though the trigger team refuses this setup). Otherwise the module could call node_update before node_save is complete. This can confuse other modules, too.

sschnuffydo’s picture

Thanks.

I am not using the trigger module, so this error message must be coming from somewhere else. I have another, possibly related error when using private_upload: When I attach a file and then preview the page it shows the message "File is not where it should be:", with no additional text for the file in question. In the list of attached files, the Description field is empty and next to the field it shows a red text: *Missing*. When I go on and save the page (despite all the messages) the file ends up in the correct place as an attachment. I do not know enough about the way uploads are handled by Drupal but it looks like there is a conflict that arises with the file paths generated by private_upload. Sorry I cannot be more specific.