When replacing a file that is located in a sub directory, the original location (manage fields > file destination) is not respected. The file is pulled out of its sub folder and upload to the ROOT of the public or private destination instead.
I think this might be a bug. Because when swapping files between private and public locations, File Entity tries to keep the sub directory path intact. You just have to make sure the same sub directories exist on both sides. But when 'replacing files' the original sub directory is not taken into account.
Could anyone please have a look? I'm a themer, not a developer, but I can help test and review possible patches.
Many thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2353351-replace-file-in-subdir.patch | 833 bytes | dave reid |
| #3 | 2353351-replace-file-in-subdir.patch | 826 bytes | dave reid |
Comments
Comment #1
markgifford commentedI can confirm this. Using 2.0-beta1.
Steps to reproduce:
- Add a file field to a content type
- In field settings, define a subdirectory "mysubdir" in which to store the files
- Create item of content, attaching the file
- Check it's uploaded to public://mysubdir
- Go to /admin/content/file, edit the file, replace the file
- The replaced file won't be in public://mysubdir, but will instead be in public://
Comment #2
yazzbe commentedComment #3
dave reidConfirmed. Looks like we're missing test coverage for this, but this should fix it in the meantime.
Comment #4
yazzbe commentedMany thanks Dave, appreciated.
I've applied the patch. However, in my local install replacing files
I got an error "destination directory is not properly configured", when trying to replace a file in the (public or private) root folder.
Comment #5
colanI think #3 needs to be using drupal_dirname(), not dirname(). Otherwise we're losing the scheme.
Comment #6
dave reidGood point, and again, lack of test coverage for this seems to be a problem. Re-rolled using drupal_dirname().
Comment #7
colanLooks good & works for me.
Comment #9
yazzbe commentedTested patch #6 against 2.0-beta-1 successfully.
Thanks guys !
Comment #11
aaron commentedCommitted to http://drupalcode.org/project/file_entity.git/commit/0dafee6.