Skip to content

Commit

Permalink
[FtpClient] fixe unwanted behaviors introduced by pr#42
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolab authored Apr 23, 2019
1 parent eedbcb0 commit 8c66e11
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/FtpClient/FtpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ public function nlist($directory = '.', $recursive = false, $filter = 'sort')
}

$result = array_unique($result);

$filter($result);

return $result;
Expand Down Expand Up @@ -372,7 +371,7 @@ public function mkdir($directory, $recursive = false)
continue;
}

if (!$this->ftp->chdir($part)) {
if (!@$this->ftp->chdir($part)) {
$result = $this->ftp->mkdir($part);
$this->ftp->chdir($part);
}
Expand Down Expand Up @@ -447,7 +446,7 @@ public function cleanDir($directory)
public function remove($path, $recursive = false)
{
try {
if ($this->ftp->delete($path)
if (@$this->ftp->delete($path)
or ($this->isDir($path) and $this->rmdir($path, $recursive))) {
return true;
}
Expand All @@ -473,7 +472,7 @@ public function isDir($directory)
throw new FtpException('Unable to resolve the current directory');
}

if ($this->ftp->chdir($directory)) {
if (@$this->ftp->chdir($directory)) {
$this->ftp->chdir($pwd);
return true;
}
Expand Down Expand Up @@ -695,7 +694,7 @@ public function getAll($source_directory, $target_directory, $mode = FTP_BINARY)
}

$this->ftp->chdir("..");
chdir ("..");
chdir("..");

return $this;
}
Expand All @@ -717,7 +716,7 @@ public function rawlist($directory = '.', $recursive = false)
throw new FtpException('"'.$directory.'" is not a directory.');
}

if (strpos($directory," ") > 0) {
if (strpos($directory, " ") > 0) {
$ftproot = $this->ftp->pwd();
$this->ftp->chdir($directory);
$list = $this->ftp->rawlist("");
Expand Down Expand Up @@ -774,7 +773,7 @@ public function rawlist($directory = '.', $recursive = false)

// ".."
or $item[$len-1] == '.' && $item[$len-2] == '.' && $item[$len-3] == ' ')
){
) {

continue;
}
Expand Down Expand Up @@ -874,16 +873,13 @@ public function parseRawList(array $rawlist)
.implode(' ', $chunks);

if ($item['type'] == 'link') {

// get the first part of 'link#the-link.ext -> /path/of/the/source.ext'
$exp = explode(' ->', $key);
$key = rtrim($exp[0]);
}

$items[$key] = $item;

} else {

// the key is the path, behavior of FtpClient::rawlist() method()
$items[$key] = $item;
}
Expand Down

0 comments on commit 8c66e11

Please sign in to comment.