Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Robin Appelman <icewind@owncloud.com>
  6. *
  7. * @copyright Copyright (c) 2015, ownCloud, Inc.
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\Files_Versions\Command;
  24. use OC\Command\FileAccess;
  25. use OCA\Files_Versions\Storage;
  26. use OCP\Command\ICommand;
  27. class Expire implements ICommand {
  28. use FileAccess;
  29. /**
  30. * @var string
  31. */
  32. private $fileName;
  33. /**
  34. * @var int|null
  35. */
  36. private $versionsSize;
  37. /**
  38. * @var int
  39. */
  40. private $neededSpace = 0;
  41. /**
  42. * @var string
  43. */
  44. private $user;
  45. /**
  46. * @param string $user
  47. * @param string $fileName
  48. * @param int|null $versionsSize
  49. * @param int $neededSpace
  50. */
  51. function __construct($user, $fileName, $versionsSize = null, $neededSpace = 0) {
  52. $this->user = $user;
  53. $this->fileName = $fileName;
  54. $this->versionsSize = $versionsSize;
  55. $this->neededSpace = $neededSpace;
  56. }
  57. public function handle() {
  58. $userManager = \OC::$server->getUserManager();
  59. if (!$userManager->userExists($this->user)) {
  60. // User has been deleted already
  61. return;
  62. }
  63. \OC_Util::setupFS($this->user);
  64. Storage::expire($this->fileName, $this->versionsSize, $this->neededSpace);
  65. \OC_Util::tearDownFS();
  66. }
  67. }