`occ preview:repair --delete` should delete whole folders
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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