aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJulius Knorr <jus@bitgrid.net>2024-09-10 09:43:42 +0200
committerJulius Knorr <jus@bitgrid.net>2024-09-10 10:13:04 +0200
commit4b333e1b404077c8ec1a11e39ac8ef6a132a77ad (patch)
treeaf00aac72f9da1f0d1c692a409198cd69a010624 /lib
parent33ccc430cfdf8ee130dd28220bcb830c6285a599 (diff)
downloadnextcloud-server-4b333e1b404077c8ec1a11e39ac8ef6a132a77ad.tar.gz
nextcloud-server-4b333e1b404077c8ec1a11e39ac8ef6a132a77ad.zip
fix: Only write once to template instead of create/copybackport/47860/stable29
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Template/TemplateManager.php4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php
index 3f3c36de5f1..46fd428b491 100644
--- a/lib/private/Files/Template/TemplateManager.php
+++ b/lib/private/Files/Template/TemplateManager.php
@@ -159,11 +159,9 @@ class TemplateManager implements ITemplateManager {
throw new GenericFileException($this->l10n->t('Invalid path'));
}
$folder = $userFolder->get(dirname($filePath));
- $targetFile = $folder->newFile(basename($filePath));
$template = null;
if ($templateType === 'user' && $templateId !== '') {
$template = $userFolder->get($templateId);
- $template->copy($targetFile->getPath());
} else {
$matchingProvider = array_filter($this->getRegisteredProviders(), function (ICustomTemplateProvider $provider) use ($templateType) {
return $templateType === get_class($provider);
@@ -171,9 +169,9 @@ class TemplateManager implements ITemplateManager {
$provider = array_shift($matchingProvider);
if ($provider) {
$template = $provider->getCustomTemplate($templateId);
- $template->copy($targetFile->getPath());
}
}
+ $targetFile = $folder->newFile(basename($filePath), ($template instanceof File ? $template->fopen('rb') : null));
$this->eventDispatcher->dispatchTyped(new FileCreatedFromTemplateEvent($template, $targetFile));
return $this->formatFile($userFolder->get($filePath));
} catch (\Exception $e) {