nextcloud / nextcloud/server

`occ preview:repair --delete` should delete whole folders

Open
#48,660 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop 30-feedback bug feature: previews and thumbnails performance 🚀
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

When running in delete mode, we don't have to loop over all the previews, delete them one-by-one and then delete the empty folder.
We can delete them directly, if their name is longer than 1 character. Only in 1 character mode we need to check and not delete any folders inside.

Code that could be added (with fixed strings and logging (which I commented out locally)):
Before:
https://github.com/nextcloud/server/blob/c109ae9437403c5bd17834c2ee53507c1d1f2ad2/core/Command/Preview/Repair.php#L214
Add:

			if (strlen($name) > 2) {
				try {
					$section1->writeln("         Delete yolo folder preview/$name", OutputInterface::VERBOSITY_VERBOSE);
					$oldPreviewFolder->delete();
					$progressBar->advance();
					continue;
				} catch (\Exception $e) {
					$this->logger->error("Failed to delete empty folder preview/$name", [
						'app' => 'core',
						'exception' => $e,
					]);
				}
			}

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 core/Command/Preview/Repair.php around line 214 and trace the occ preview:repair --delete path. Check how folder names are handled and preserve the special behavior for one-character folders. Done means delete mode removes eligible preview folders directly while retaining the protected-folder behavior and existing error logging.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.