Skip to content

Commit e3c7bb4

Browse files
committed
Add a parameter to optionally copy the file, but it will still be moved by default
1 parent 6156406 commit e3c7bb4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

wcfsetup/install/files/lib/data/file/FileEditor.class.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public static function createFromTemporary(FileTemporary $fileTemporary): File
117117
public static function createFromExistingFile(
118118
string $pathname,
119119
string $originalFilename,
120-
string $objectTypeName
120+
string $objectTypeName,
121+
bool $copy = false
121122
): ?File {
122123
if (!\is_readable($pathname)) {
123124
return null;
@@ -174,10 +175,11 @@ public static function createFromExistingFile(
174175
\mkdir($filePath, recursive: true);
175176
}
176177

177-
\rename(
178-
$pathname,
179-
$filePath . $file->getSourceFilename()
180-
);
178+
if ($copy) {
179+
\copy($pathname, $filePath . $file->getSourceFilename());
180+
} else {
181+
\rename($pathname, $filePath . $file->getSourceFilename());
182+
}
181183

182184
return $file;
183185
}

0 commit comments

Comments
 (0)