When attempting to create content for nodes with file fields, if no previous data has been entered (Sucessfully) then the , chosen file storage directory does not exist. This produces errors such as

File temporary://filefield_HTNlWB.txt could not be copied, because the destination directory ..../sites/default/files/ is not configured correctly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arcticShadow’s picture

Attached a patch which fixes the issue for me.

salvis’s picture

Have you tried configuring the directory?

Usually, Drupal creates it when you configure it, and it creates it with a .htaccess fiile that's needed.

moshe weitzman’s picture

Status: Active » Closed (works as designed)

yeah, pretty sure this is a symptom of not setting up drupal's file storage. drupal already warns when you do that.

arcticShadow’s picture

Status: Closed (works as designed) » Active

The thing is with this that for image field types, the directory is created on the fly, same location (different name of course) as files should be created.

Comparing the images generate script to the files generate script, Images has a create_directory_if_not_exist flag at the end of the move-generated-file command.

I'm relatively new to drupal and even newer to community contribution and patching, But I don't think devel_generate is meant to fail when creating files but succeed when creating images. in the scenario when neither node_image or node_files directories exists before the generate.

pavelsof’s picture

I came across the same problem but manually creating some content beforehand seems to fix it nicely.

Alan D.’s picture

There still appears to be a couple of errors here (Note that the file directory IS being created in the latest DEV version):

The functions file_unmanaged_move() and file_move() expect the FILE_EXISTS_RENAME constants, but are getting the FILE_CREATE_DIRECTORY constants.

ie: the function is replacing the existing file if there is a conflict.

define('FILE_EXISTS_REPLACE', 1);
define('FILE_CREATE_DIRECTORY', 1);

And this looks like it could need work to integrate with File entity (fieldable files) module. Currently, I get random errors about bundle IDs missing via an EntityMalformedException being thrown. This was due to conflicts in file_move() during generation via xxx_move(FILE_CREATE_DIRECTORY) issues addressed in the patch. If I come across this again, I report a new issue to the relevant queue and cross post.

hansrossel’s picture

In my case these errors were caused by the fact that I only allowed pdf as file extension for the filefield while devel_generate only generates txt files. So adding txt again as allowed extension for the filefields fixed it.

Alan D.’s picture

The latest dev version should work without any issues (hashed file name from memory - so very low chance of conflicts in the file names), however the changes above still apply.

salvis’s picture

Can we close #1175142: Generating content failed with numerous notice and warning message as a duplicate of this?

@Alan D.: Are you saying that your patch is not needed anymore?

Alan D.’s picture

Nope, but it's a bug that has minimal chances of ever being hit. Correcting the usage of the File API really. Other related threads here already appear resolved and the point hansrossel raised appears to be a new issue (at least it appears different from initial points raised late last year in both threads).

salvis’s picture

Status: Active » Needs review

I'm a bit confused by this thread.

@arcticShadow:

Comparing the images generate script to the files generate script, Images has a create_directory_if_not_exist flag at the end of the move-generated-file command.

Your patch in #1 adds FILE_CREATE_DIRECTORY to the file_move() call. FILE_CREATE_DIRECTORY is not among the constants that are allowed for file_move(), and I doubt, whether your interpretation is correct.

@Alan D. #6:

Note that the file directory IS being created in the latest DEV version

So we should have closed this issue as WAD and #6 should have gone into a new thread, right?

FILE_CREATE_DIRECTORY (1) is definitely the wrong constant for file_move(), the 1 means FILE_EXISTS_REPLACE, as you point out. Removing it makes it default to FILE_EXISTS_RENAME (0), which is probably what was intended.

I think we should commit #6.

Status: Needs review » Needs work

The last submitted patch, devel-create-tmp-dir-issue-1210300-6.patch, failed testing.

acoustika’s picture

Im getting this error also..... With image field, and yes it seems like its because i have configured my public filesystem and the image field with a token....
For the particular image field I have a path like files/images/[User-uid]
And i can create conten manually but devel will not create directories on the fly in a situation like this it seems,
I have newest dev version of pretty much all on my site....

blackspiraldancer’s picture

Same situation here. I managed to make the error completely disappear removing all tokens inside the image file path, within the field configuration (that's obviously not the desired behavior).

Dave Reid’s picture

Issue summary: View changes
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.