From 5b09806f8b16bac82b7a0020770574a62595ecca Mon Sep 17 00:00:00 2001 From: BePsvPT Date: Mon, 18 Jul 2016 22:05:01 +0800 Subject: [PATCH 1/2] Optimize Filesystem moveDirectory --- src/Illuminate/Filesystem/Filesystem.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index 453ae1849f2f..667fbe7c40e2 100644 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -401,13 +401,11 @@ public function makeDirectory($path, $mode = 0755, $recursive = false, $force = public function moveDirectory($from, $to, $overwrite = false) { if ($overwrite && $this->isDirectory($to)) { - $this->deleteDirectory($to); - - $this->copyDirectory($from, $to); - - $this->deleteDirectory($from); + if (! $this->deleteDirectory($to)) { + return false; + } - return true; + return @rename($from, $to) === true; } return @rename($from, $to) === true; From a4115011b52c549b22db496283d3ff986c02aade Mon Sep 17 00:00:00 2001 From: BePsvPT Date: Tue, 19 Jul 2016 09:05:33 +0800 Subject: [PATCH 2/2] Remove redundant code --- src/Illuminate/Filesystem/Filesystem.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index 667fbe7c40e2..e02bf6cc3771 100644 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -404,8 +404,6 @@ public function moveDirectory($from, $to, $overwrite = false) if (! $this->deleteDirectory($to)) { return false; } - - return @rename($from, $to) === true; } return @rename($from, $to) === true;