From: Cyperghost Date: Mon, 18 Nov 2024 11:47:31 +0000 (+0100) Subject: Add a parameter to optionally copy the file, but it will still be moved by default X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e3c7bb41b890c8a124c9d385731a955630ea3f13;p=GitHub%2FWoltLab%2FWCF.git Add a parameter to optionally copy the file, but it will still be moved by default --- diff --git a/wcfsetup/install/files/lib/data/file/FileEditor.class.php b/wcfsetup/install/files/lib/data/file/FileEditor.class.php index 50564a6e8d..d3e5ac3d57 100644 --- a/wcfsetup/install/files/lib/data/file/FileEditor.class.php +++ b/wcfsetup/install/files/lib/data/file/FileEditor.class.php @@ -117,7 +117,8 @@ class FileEditor extends DatabaseObjectEditor public static function createFromExistingFile( string $pathname, string $originalFilename, - string $objectTypeName + string $objectTypeName, + bool $copy = false ): ?File { if (!\is_readable($pathname)) { return null; @@ -174,10 +175,11 @@ class FileEditor extends DatabaseObjectEditor \mkdir($filePath, recursive: true); } - \rename( - $pathname, - $filePath . $file->getSourceFilename() - ); + if ($copy) { + \copy($pathname, $filePath . $file->getSourceFilename()); + } else { + \rename($pathname, $filePath . $file->getSourceFilename()); + } return $file; }