Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When the directory is '/', all the files contain a leading '/'. This can be solved by stripping the / from the filenames, or not appending the extra '/' in feeds_ftp_fetcher_list()
$filename = str_replace($directory == '/' ? '/' : $directory . '/', '', $filename);
or
$filename = str_replace($directory, '', $filename);
$filename = ltrim($filename, '/');
Comment | File | Size | Author |
---|---|---|---|
#2 | feeds_ftp_fetcher-strip-directory-prefix-2481411-2.patch | 732 bytes | lwalley |
#1 | 2481411.patch | 855 bytes | dready2011 |
Comments
Comment #1
dready2011 CreditAttribution: dready2011 commentedI can confirm this problem, was not able to fetch files from the root directory. Barrys solution solved the issue for me, thanks for that!
I created a patch for others stumbling upon this problem.
Comment #2
lwalley CreditAttribution: lwalley commentedWithout count it appears str_replace will replace all occurrences, i.e. if there are subdirectories with the same name then they would also get stripped e.g. if directory is "/dir/" and inside that there is subdirectory i.e. "/dir/dir/" then both will be stripped. And with the patch in #1 if directory is "/" then all "/" will be removed i.e. "/dir/dir/" will become "dirdir"... not sure if any of that matters i.e. whether subdirectories are included in the files list, but I'm adding a new patch that attempts to use preg_replace to only strip the value of "directory" config from the beginning of the filename followed by a forward slash. This should also account for "directory" config set to just "/".