Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function index($dir = '', $view = '', $fileid = null) {
$this->eventDispatcher->dispatchTyped(new LoadViewer());
}

$this->initialState->provideInitialState('templates_enabled', ($this->config->getSystemValueString('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton') !== '') || ($this->config->getSystemValueString('templatedirectory', \OC::$SERVERROOT . '/core/skeleton/Templates') !== ''));
$this->initialState->provideInitialState('templates_enabled', true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make the button appear even if it may do nothing?

Copy link
Contributor Author

@benjaminfrueh benjaminfrueh Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my tests the button always works correctly even if both configurations are empty. It manually creates a template directory in the users directory and is only available for users who don't have a template directory configured yet.

This wasn't working before because the condition in initializeTemplateDirectory was blocking it even when coming from a manual user request, not from the automatic initialization on new user setup.

The change was originally implemented to prevent the automatic creation of the template folder, the manual creation is a feature a user could always opt-in and use.

So in my opinion the manual creation could always be possible regardless of both configurations. If the nextcloud configurated templatedirectory is a empty string, no files will be seeded automatically from there, but the user can still create it and add their own templates to it.

$this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false);
$this->initialState->provideInitialState('templates', $this->templateManager->listCreators());

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Template/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function initializeTemplateDirectory(?string $path = null, ?string $userI
$isDefaultTemplates = $skeletonTemplatePath === $defaultTemplateDirectory;
$userLang = $this->l10nFactory->getUserLanguage($this->userManager->get($this->userId));

if ($skeletonTemplatePath === '') {
if ($path === null && $skeletonTemplatePath === '' && $skeletonPath === '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is $path also checked now?

Copy link
Contributor Author

@benjaminfrueh benjaminfrueh Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path check is to prevent the template dir creation only for the automatic initialization setup (when a user is created). For the manual creation with the button in the Web UI, there is always a path given. The same path check is used a few lines later to detect initial user setup.

$this->setTemplatePath('');
return '';
}
Expand Down
Loading