From 387c6e52d61c2c2ac6b7624c1ab432105d6b0590 Mon Sep 17 00:00:00 2001 From: Mohammad Morakabati Date: Wed, 11 Dec 2024 23:17:13 +0330 Subject: [PATCH] Update FtpAdapter.php fix: solve issue with checking folder existence using FTP --- src/Ftp/FtpAdapter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Ftp/FtpAdapter.php b/src/Ftp/FtpAdapter.php index b15add8dc..73a53bc69 100644 --- a/src/Ftp/FtpAdapter.php +++ b/src/Ftp/FtpAdapter.php @@ -592,12 +592,14 @@ private function ensureDirectoryExists(string $dirname, ?string $visibility): vo $dirPath = ''; $parts = explode('/', trim($dirname, '/')); $mode = $visibility ? $this->visibilityConverter->forDirectory($visibility) : false; + $original_directory = @ftp_pwd($connection); foreach ($parts as $part) { $dirPath .= '/' . $part; $location = $this->prefixer()->prefixPath($dirPath); if (@ftp_chdir($connection, $location)) { + @ftp_chdir($connection, $original_directory); continue; }