Skip to content

Commit

Permalink
Properly handle creating the template directory in a subfolder (fixes #…
Browse files Browse the repository at this point in the history
…25787)

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Apr 1, 2021
1 parent 37591f0 commit 6fd5714
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 6fd5714

Please sign in to comment.