fix:修复BUG/升级1.1.6版本
This commit is contained in:
33
vendor/workerman/webman-framework/src/File.php
vendored
33
vendor/workerman/webman-framework/src/File.php
vendored
@@ -14,31 +14,42 @@
|
||||
|
||||
namespace Webman;
|
||||
|
||||
use SplFileInfo;
|
||||
use Webman\Exception\FileException;
|
||||
use function chmod;
|
||||
use function is_dir;
|
||||
use function mkdir;
|
||||
use function pathinfo;
|
||||
use function restore_error_handler;
|
||||
use function set_error_handler;
|
||||
use function sprintf;
|
||||
use function strip_tags;
|
||||
use function umask;
|
||||
|
||||
class File extends \SplFileInfo
|
||||
class File extends SplFileInfo
|
||||
{
|
||||
|
||||
/**
|
||||
* Move.
|
||||
* @param string $destination
|
||||
* @return File
|
||||
*/
|
||||
public function move(string $destination)
|
||||
public function move(string $destination): File
|
||||
{
|
||||
\set_error_handler(function ($type, $msg) use (&$error) {
|
||||
set_error_handler(function ($type, $msg) use (&$error) {
|
||||
$error = $msg;
|
||||
});
|
||||
$path = \pathinfo($destination, PATHINFO_DIRNAME);
|
||||
if (!\is_dir($path) && !\mkdir($path, 0777, true)) {
|
||||
\restore_error_handler();
|
||||
throw new FileException(\sprintf('Unable to create the "%s" directory (%s)', $path, \strip_tags($error)));
|
||||
$path = pathinfo($destination, PATHINFO_DIRNAME);
|
||||
if (!is_dir($path) && !mkdir($path, 0777, true)) {
|
||||
restore_error_handler();
|
||||
throw new FileException(sprintf('Unable to create the "%s" directory (%s)', $path, strip_tags($error)));
|
||||
}
|
||||
if (!rename($this->getPathname(), $destination)) {
|
||||
\restore_error_handler();
|
||||
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $destination, \strip_tags($error)));
|
||||
restore_error_handler();
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $destination, strip_tags($error)));
|
||||
}
|
||||
\restore_error_handler();
|
||||
@\chmod($destination, 0666 & ~\umask());
|
||||
restore_error_handler();
|
||||
@chmod($destination, 0666 & ~umask());
|
||||
return new self($destination);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user