Hello,

I've found that file_module can't create directory path recursively. This happens because it uses drupal's built-in file_check_directory() function which do not offer this feature. Here is small patch to avoid this issue.

Comments

Status: Needs review » Needs work

The last submitted patch, file_service.inc_.patch, failed testing.

pavel.karoukin’s picture

Status: Needs work » Needs review
StatusFileSize
new540 bytes

indeed =))

Status: Needs review » Needs work

The last submitted patch, file_service.inc_.patch, failed testing.

kylebrowning’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

Setting to needs review for patch test. Also IM not sure if this is needed functionality so I wont commit this patch until heyrocker signs off on it.

kylebrowning’s picture

Status: Needs review » Reviewed & tested by the community
kylebrowning’s picture

Version: 6.x-2.0 » 6.x-2.x-dev

Set to dev so the patch passes

kylebrowning’s picture

Status: Reviewed & tested by the community » Needs review

Im smoking crack sorry, leaving as review until test passes.

kylebrowning’s picture

Status: Needs review » Fixed

Ok, just waiting on heyrocker for this now , hehe.

kylebrowning’s picture

Status: Fixed » Reviewed & tested by the community
gdd’s picture

I'm a little torn on this, because I feel like our file.save functionality should work under the same assumptions that core does in order to reduce confusion. Gimme a day to think about it.

kylebrowning’s picture

Precisely why I thought it best to talk to you about it. I feel like it should be working in core, and I was not able to replicate this as a bug, but I wrote the patch anyway just in case.

marcingy’s picture

Status: Reviewed & tested by the community » Needs work

#4 has somes view changes in it as well which seems wrong

kylebrowning’s picture

Status: Needs work » Needs review
StatusFileSize
new939 bytes

Patch re-roll

johannesdr’s picture

It looks like this has been fixed in Drupal 7: #515280: file_check_directory() should create recursively
and it has also been reported for Drupal 6: #180970: file_check_directory fails to make directories if the parent doesn't already exist

The patch in #13 works for me, but wouldn't it be cleaner to do

$full_path = '';
foreach (explode('/', $dir) as $path) {
  $full_path .= $path . '/';
  if (!file_check_directory($full_path, FILE_CREATE_DIRECTORY)) {
    return services_error(t("Could not create destination directory for file."));
  }
}
kylebrowning’s picture

Status: Needs review » Closed (won't fix)

This is a core issue and should be fixed in core soon.