nextcloud / nextcloud/previewgenerator

`OCP\Files\NotPermittedException` `Could not create folder`

Open
#289 34 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop bug
Dominant language
PHP
Stars
520
Forks
55
PR merge metrics
No merged PRs in 30d

Description

I had a similar issue with Nextcloud 22.2.4:

2022-02-06T10:01:50+00:00 In Folder.php line 173:
2022-02-06T10:01:50+00:00                                         
2022-02-06T10:01:50+00:00   [OCP\Files\NotPermittedException]     
2022-02-06T10:01:50+00:00   Could not create folder: {$fullPath}  
2022-02-06T10:01:50+00:00                                         
2022-02-06T10:01:50+00:00 
2022-02-06T10:01:50+00:00 Exception trace:
2022-02-06T10:01:50+00:00   at /var/www/html/lib/private/Files/Node/Folder.php:173
2022-02-06T10:01:50+00:00  OC\Files\Node\Folder->newFolder() at /var/www/html/lib/private/Files/AppData/AppData.php:156
2022-02-06T10:01:50+00:00  OC\Files\AppData\AppData->newFolder() at /var/www/html/lib/private/Preview/Storage/Root.php:74
2022-02-06T10:01:50+00:00  OC\Preview\Storage\Root->newFolder() at /var/www/html/lib/private/Preview/Generator.php:472
2022-02-06T10:01:50+00:00  OC\Preview\Generator->getPreviewFolder() at /var/www/html/lib/private/Preview/Generator.php:132
2022-02-06T10:01:50+00:00  OC\Preview\Generator->generatePreviews() at /var/www/html/lib/private/PreviewManager.php:204
2022-02-06T10:01:50+00:00  OC\PreviewManager->generatePreviews() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:243
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->parseFile() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:214
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:212
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:212
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:212
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:183
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->generatePathPreviews() at /var/www/html/custom_apps/previewgenerator/lib/Command/Generate.php:131
2022-02-06T10:01:50+00:00  OCA\PreviewGenerator\Command\Generate->execute() at /var/www/html/3rdparty/symfony/console/Command/Command.php:255
2022-02-06T10:01:50+00:00  Symfony\Component\Console\Command\Command->run() at /var/www/html/3rdparty/symfony/console/Application.php:1009
2022-02-06T10:01:50+00:00  Symfony\Component\Console\Application->doRunCommand() at /var/www/html/3rdparty/symfony/console/Application.php:273
2022-02-06T10:01:50+00:00  Symfony\Component\Console\Application->doRun() at /var/www/html/3rdparty/symfony/console/Application.php:149
2022-02-06T10:01:50+00:00  Symfony\Component\Console\Application->run() at /var/www/html/lib/private/Console/Application.php:209
2022-02-06T10:01:50+00:00  OC\Console\Application->run() at /var/www/html/console.php:99
2022-02-06T10:01:50+00:00  require_once() at /var/www/html/occ:11

I added a log output in
nextcloud/lib/private/Files/Node/Folder.php:173:
throw new NotPermittedException('Could not create folder, fullPath: '.$fullPath.', path: '.$path);

After i checked and the folder did exist for me. So to fix this i added a check on the creation if the folder already exists to fix this and changed it to:
if (!$this->get($path) || !$this->view->mkdir($fullPath)) { throw new NotPermittedException('Could not create folder, fullPath: '.$fullPath.', path: '.$path); }

Originally posted by @f4t-t0ny in https://github.com/nextcloud/previewgenerator/issues/121#issuecomment-1030803305

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/private/Files/Node/Folder.php at line 173 and trace the folder creation calls shown through lib/private/Preview/Storage/Root.php and lib/private/Preview/Generator.php. Compare the reported existing-folder condition with the previewgenerator command paths in lib/Command/Generate.php, then verify that the error is no longer raised incorrectly when the folder already exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.