🐛 修复 BUG

This commit is contained in:
WispX
2020-02-29 23:38:33 +08:00
parent e3880f50e7
commit 3576d40dc9
2 changed files with 20 additions and 3 deletions
+3 -2
View File
@@ -91,8 +91,9 @@ class Upload extends Base
$url = make_url($domain, $pathname);
// 检测是否存在该图片,有则直接返回
if ($oldImage = Images::where('md5', $md5)->find()) {
$url = make_url($domain, $oldImage->pathname);
if ($oldImage = Images::where('md5', $md5)->where('strategy', $currentStrategy)->find()) {
$pathname = $oldImage->pathname;
$url = make_url($domain, $pathname);
goto exist;
}
+17 -1
View File
@@ -23,7 +23,7 @@ class Remote implements Driver
try {
$this->ftp = new \FtpClient\FtpClient();
$this->ftp->connect($options['remote_host']);
$this->ftp->login($options['remote_name'], $options['remote_password']);
$this->ftp = $this->ftp->login($options['remote_name'], $options['remote_password']);
} catch (FtpException $e) {
$this->error = $e->getMessage();
}
@@ -39,6 +39,8 @@ class Remote implements Driver
*/
public function create($pathname, $file)
{
if (!$this->check()) return false;
try {
$dirname = dirname($pathname);
if (!$this->ftp->isDir($dirname)) {
@@ -66,6 +68,8 @@ class Remote implements Driver
*/
public function delete($pathname)
{
if (!$this->check()) return false;
try {
if (!$this->ftp->remove($pathname, true)) {
throw new FtpException('删除失败');
@@ -87,6 +91,8 @@ class Remote implements Driver
*/
public function deletes(array $list)
{
if (!$this->check()) return false;
try {
foreach ($list as $item) {
if (!$this->ftp->remove($item, true)) {
@@ -110,4 +116,14 @@ class Remote implements Driver
{
return 'Remote' . $this->error;
}
private function check()
{
if (!extension_loaded('ftp')) {
$this->error = 'php_ftp 拓展未开启';
return false;
}
return true;
}
}