Skip to content

Commit 8c66e11

Browse files
authored
[FtpClient] fixe unwanted behaviors introduced by pr#42
1 parent eedbcb0 commit 8c66e11

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/FtpClient/FtpClient.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ public function nlist($directory = '.', $recursive = false, $filter = 'sort')
339339
}
340340

341341
$result = array_unique($result);
342-
343342
$filter($result);
344343

345344
return $result;
@@ -372,7 +371,7 @@ public function mkdir($directory, $recursive = false)
372371
continue;
373372
}
374373

375-
if (!$this->ftp->chdir($part)) {
374+
if (!@$this->ftp->chdir($part)) {
376375
$result = $this->ftp->mkdir($part);
377376
$this->ftp->chdir($part);
378377
}
@@ -447,7 +446,7 @@ public function cleanDir($directory)
447446
public function remove($path, $recursive = false)
448447
{
449448
try {
450-
if ($this->ftp->delete($path)
449+
if (@$this->ftp->delete($path)
451450
or ($this->isDir($path) and $this->rmdir($path, $recursive))) {
452451
return true;
453452
}
@@ -473,7 +472,7 @@ public function isDir($directory)
473472
throw new FtpException('Unable to resolve the current directory');
474473
}
475474

476-
if ($this->ftp->chdir($directory)) {
475+
if (@$this->ftp->chdir($directory)) {
477476
$this->ftp->chdir($pwd);
478477
return true;
479478
}
@@ -695,7 +694,7 @@ public function getAll($source_directory, $target_directory, $mode = FTP_BINARY)
695694
}
696695

697696
$this->ftp->chdir("..");
698-
chdir ("..");
697+
chdir("..");
699698

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

720-
if (strpos($directory," ") > 0) {
719+
if (strpos($directory, " ") > 0) {
721720
$ftproot = $this->ftp->pwd();
722721
$this->ftp->chdir($directory);
723722
$list = $this->ftp->rawlist("");
@@ -774,7 +773,7 @@ public function rawlist($directory = '.', $recursive = false)
774773

775774
// ".."
776775
or $item[$len-1] == '.' && $item[$len-2] == '.' && $item[$len-3] == ' ')
777-
){
776+
) {
778777

779778
continue;
780779
}
@@ -874,16 +873,13 @@ public function parseRawList(array $rawlist)
874873
.implode(' ', $chunks);
875874

876875
if ($item['type'] == 'link') {
877-
878876
// get the first part of 'link#the-link.ext -> /path/of/the/source.ext'
879877
$exp = explode(' ->', $key);
880878
$key = rtrim($exp[0]);
881879
}
882880

883881
$items[$key] = $item;
884-
885882
} else {
886-
887883
// the key is the path, behavior of FtpClient::rawlist() method()
888884
$items[$key] = $item;
889885
}

0 commit comments

Comments
 (0)