Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Properly handle creating the template directory in a subfolder (fixes #…
…25787)

Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Apr 1, 2021
commit 6fd571461c32fc46c63943454c5087064a96b759
6 changes: 3 additions & 3 deletions lib/private/Files/Template/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\Template\FileCreatedFromTemplateEvent;
use OCP\Files\Template\ICustomTemplateProvider;
use OCP\Files\Template\ITemplateManager;
Expand Down Expand Up @@ -300,9 +299,10 @@ public function initializeTemplateDirectory(string $path = null, string $userId
}

try {
$folder = $userFolder->newFolder($userTemplatePath);
} catch (NotPermittedException $e) {
$folder = $userFolder->get($userTemplatePath);
} catch (NotFoundException $e) {
$folder = $userFolder->get(dirname($userTemplatePath));
$folder = $folder->newFolder(basename($userTemplatePath));
}

$folderIsEmpty = count($folder->getDirectoryListing()) === 0;
Expand Down