preview.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @author Georg Ehrke <georg@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OC\Repair;
  22. use OC\Files\View;
  23. use OC\Hooks\BasicEmitter;
  24. class Preview extends BasicEmitter implements \OC\RepairStep {
  25. public function getName() {
  26. return 'Cleaning-up broken previews';
  27. }
  28. public function run() {
  29. $view = new View('/');
  30. $children = $view->getDirectoryContent('/');
  31. foreach ($children as $child) {
  32. if ($view->is_dir($child->getPath())) {
  33. $thumbnailsFolder = $child->getPath() . '/thumbnails';
  34. if ($view->is_dir($thumbnailsFolder)) {
  35. $view->rmdir($thumbnailsFolder);
  36. }
  37. }
  38. }
  39. }
  40. }