@@ -55,169 +55,169 @@ |
||
| 55 | 55 | use Symfony\Component\EventDispatcher\GenericEvent; |
| 56 | 56 | |
| 57 | 57 | class Repair implements IOutput{ |
| 58 | - /* @var IRepairStep[] */ |
|
| 59 | - private $repairSteps; |
|
| 60 | - /** @var EventDispatcher */ |
|
| 61 | - private $dispatcher; |
|
| 62 | - /** @var string */ |
|
| 63 | - private $currentStep; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Creates a new repair step runner |
|
| 67 | - * |
|
| 68 | - * @param IRepairStep[] $repairSteps array of RepairStep instances |
|
| 69 | - * @param EventDispatcher $dispatcher |
|
| 70 | - */ |
|
| 71 | - public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) { |
|
| 72 | - $this->repairSteps = $repairSteps; |
|
| 73 | - $this->dispatcher = $dispatcher; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Run a series of repair steps for common problems |
|
| 78 | - */ |
|
| 79 | - public function run() { |
|
| 80 | - if (count($this->repairSteps) === 0) { |
|
| 81 | - $this->emit('\OC\Repair', 'info', array('No repair steps available')); |
|
| 82 | - return; |
|
| 83 | - } |
|
| 84 | - // run each repair step |
|
| 85 | - foreach ($this->repairSteps as $step) { |
|
| 86 | - $this->currentStep = $step->getName(); |
|
| 87 | - $this->emit('\OC\Repair', 'step', [$this->currentStep]); |
|
| 88 | - $step->run($this); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Add repair step |
|
| 94 | - * |
|
| 95 | - * @param IRepairStep|string $repairStep repair step |
|
| 96 | - * @throws \Exception |
|
| 97 | - */ |
|
| 98 | - public function addStep($repairStep) { |
|
| 99 | - if (is_string($repairStep)) { |
|
| 100 | - try { |
|
| 101 | - $s = \OC::$server->query($repairStep); |
|
| 102 | - } catch (QueryException $e) { |
|
| 103 | - if (class_exists($repairStep)) { |
|
| 104 | - $s = new $repairStep(); |
|
| 105 | - } else { |
|
| 106 | - throw new \Exception("Repair step '$repairStep' is unknown"); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if ($s instanceof IRepairStep) { |
|
| 111 | - $this->repairSteps[] = $s; |
|
| 112 | - } else { |
|
| 113 | - throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); |
|
| 114 | - } |
|
| 115 | - } else { |
|
| 116 | - $this->repairSteps[] = $repairStep; |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Returns the default repair steps to be run on the |
|
| 122 | - * command line or after an upgrade. |
|
| 123 | - * |
|
| 124 | - * @return IRepairStep[] |
|
| 125 | - */ |
|
| 126 | - public static function getRepairSteps() { |
|
| 127 | - return [ |
|
| 128 | - new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false), |
|
| 129 | - new RepairMimeTypes(\OC::$server->getConfig()), |
|
| 130 | - new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()), |
|
| 131 | - new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), |
|
| 132 | - new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()), |
|
| 133 | - new MoveUpdaterStepFile(\OC::$server->getConfig()), |
|
| 134 | - new FixMountStorages(\OC::$server->getDatabaseConnection()), |
|
| 135 | - new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), |
|
| 136 | - new AddLogRotateJob(\OC::$server->getJobList()), |
|
| 137 | - new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)), |
|
| 138 | - new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), |
|
| 139 | - new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), |
|
| 140 | - ]; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Returns expensive repair steps to be run on the |
|
| 145 | - * command line with a special option. |
|
| 146 | - * |
|
| 147 | - * @return IRepairStep[] |
|
| 148 | - */ |
|
| 149 | - public static function getExpensiveRepairSteps() { |
|
| 150 | - return [ |
|
| 151 | - new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()), |
|
| 152 | - ]; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Returns the repair steps to be run before an |
|
| 157 | - * upgrade. |
|
| 158 | - * |
|
| 159 | - * @return IRepairStep[] |
|
| 160 | - */ |
|
| 161 | - public static function getBeforeUpgradeRepairSteps() { |
|
| 162 | - $connection = \OC::$server->getDatabaseConnection(); |
|
| 163 | - $config = \OC::$server->getConfig(); |
|
| 164 | - $steps = [ |
|
| 165 | - new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true), |
|
| 166 | - new SqliteAutoincrement($connection), |
|
| 167 | - new SaveAccountsTableData($connection, $config), |
|
| 168 | - new DropAccountTermsTable($connection), |
|
| 169 | - ]; |
|
| 170 | - |
|
| 171 | - return $steps; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @param string $scope |
|
| 176 | - * @param string $method |
|
| 177 | - * @param array $arguments |
|
| 178 | - */ |
|
| 179 | - public function emit($scope, $method, array $arguments = []) { |
|
| 180 | - if (!is_null($this->dispatcher)) { |
|
| 181 | - $this->dispatcher->dispatch("$scope::$method", |
|
| 182 | - new GenericEvent("$scope::$method", $arguments)); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - public function info($string) { |
|
| 187 | - // for now just emit as we did in the past |
|
| 188 | - $this->emit('\OC\Repair', 'info', array($string)); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * @param string $message |
|
| 193 | - */ |
|
| 194 | - public function warning($message) { |
|
| 195 | - // for now just emit as we did in the past |
|
| 196 | - $this->emit('\OC\Repair', 'warning', [$message]); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @param int $max |
|
| 201 | - */ |
|
| 202 | - public function startProgress($max = 0) { |
|
| 203 | - // for now just emit as we did in the past |
|
| 204 | - $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * @param int $step |
|
| 209 | - * @param string $description |
|
| 210 | - */ |
|
| 211 | - public function advance($step = 1, $description = '') { |
|
| 212 | - // for now just emit as we did in the past |
|
| 213 | - $this->emit('\OC\Repair', 'advance', [$step, $description]); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * @param int $max |
|
| 218 | - */ |
|
| 219 | - public function finishProgress() { |
|
| 220 | - // for now just emit as we did in the past |
|
| 221 | - $this->emit('\OC\Repair', 'finishProgress', []); |
|
| 222 | - } |
|
| 58 | + /* @var IRepairStep[] */ |
|
| 59 | + private $repairSteps; |
|
| 60 | + /** @var EventDispatcher */ |
|
| 61 | + private $dispatcher; |
|
| 62 | + /** @var string */ |
|
| 63 | + private $currentStep; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Creates a new repair step runner |
|
| 67 | + * |
|
| 68 | + * @param IRepairStep[] $repairSteps array of RepairStep instances |
|
| 69 | + * @param EventDispatcher $dispatcher |
|
| 70 | + */ |
|
| 71 | + public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) { |
|
| 72 | + $this->repairSteps = $repairSteps; |
|
| 73 | + $this->dispatcher = $dispatcher; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Run a series of repair steps for common problems |
|
| 78 | + */ |
|
| 79 | + public function run() { |
|
| 80 | + if (count($this->repairSteps) === 0) { |
|
| 81 | + $this->emit('\OC\Repair', 'info', array('No repair steps available')); |
|
| 82 | + return; |
|
| 83 | + } |
|
| 84 | + // run each repair step |
|
| 85 | + foreach ($this->repairSteps as $step) { |
|
| 86 | + $this->currentStep = $step->getName(); |
|
| 87 | + $this->emit('\OC\Repair', 'step', [$this->currentStep]); |
|
| 88 | + $step->run($this); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Add repair step |
|
| 94 | + * |
|
| 95 | + * @param IRepairStep|string $repairStep repair step |
|
| 96 | + * @throws \Exception |
|
| 97 | + */ |
|
| 98 | + public function addStep($repairStep) { |
|
| 99 | + if (is_string($repairStep)) { |
|
| 100 | + try { |
|
| 101 | + $s = \OC::$server->query($repairStep); |
|
| 102 | + } catch (QueryException $e) { |
|
| 103 | + if (class_exists($repairStep)) { |
|
| 104 | + $s = new $repairStep(); |
|
| 105 | + } else { |
|
| 106 | + throw new \Exception("Repair step '$repairStep' is unknown"); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if ($s instanceof IRepairStep) { |
|
| 111 | + $this->repairSteps[] = $s; |
|
| 112 | + } else { |
|
| 113 | + throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep"); |
|
| 114 | + } |
|
| 115 | + } else { |
|
| 116 | + $this->repairSteps[] = $repairStep; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Returns the default repair steps to be run on the |
|
| 122 | + * command line or after an upgrade. |
|
| 123 | + * |
|
| 124 | + * @return IRepairStep[] |
|
| 125 | + */ |
|
| 126 | + public static function getRepairSteps() { |
|
| 127 | + return [ |
|
| 128 | + new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false), |
|
| 129 | + new RepairMimeTypes(\OC::$server->getConfig()), |
|
| 130 | + new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()), |
|
| 131 | + new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), |
|
| 132 | + new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()), |
|
| 133 | + new MoveUpdaterStepFile(\OC::$server->getConfig()), |
|
| 134 | + new FixMountStorages(\OC::$server->getDatabaseConnection()), |
|
| 135 | + new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), |
|
| 136 | + new AddLogRotateJob(\OC::$server->getJobList()), |
|
| 137 | + new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)), |
|
| 138 | + new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), |
|
| 139 | + new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), |
|
| 140 | + ]; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Returns expensive repair steps to be run on the |
|
| 145 | + * command line with a special option. |
|
| 146 | + * |
|
| 147 | + * @return IRepairStep[] |
|
| 148 | + */ |
|
| 149 | + public static function getExpensiveRepairSteps() { |
|
| 150 | + return [ |
|
| 151 | + new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()), |
|
| 152 | + ]; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Returns the repair steps to be run before an |
|
| 157 | + * upgrade. |
|
| 158 | + * |
|
| 159 | + * @return IRepairStep[] |
|
| 160 | + */ |
|
| 161 | + public static function getBeforeUpgradeRepairSteps() { |
|
| 162 | + $connection = \OC::$server->getDatabaseConnection(); |
|
| 163 | + $config = \OC::$server->getConfig(); |
|
| 164 | + $steps = [ |
|
| 165 | + new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true), |
|
| 166 | + new SqliteAutoincrement($connection), |
|
| 167 | + new SaveAccountsTableData($connection, $config), |
|
| 168 | + new DropAccountTermsTable($connection), |
|
| 169 | + ]; |
|
| 170 | + |
|
| 171 | + return $steps; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * @param string $scope |
|
| 176 | + * @param string $method |
|
| 177 | + * @param array $arguments |
|
| 178 | + */ |
|
| 179 | + public function emit($scope, $method, array $arguments = []) { |
|
| 180 | + if (!is_null($this->dispatcher)) { |
|
| 181 | + $this->dispatcher->dispatch("$scope::$method", |
|
| 182 | + new GenericEvent("$scope::$method", $arguments)); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + public function info($string) { |
|
| 187 | + // for now just emit as we did in the past |
|
| 188 | + $this->emit('\OC\Repair', 'info', array($string)); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * @param string $message |
|
| 193 | + */ |
|
| 194 | + public function warning($message) { |
|
| 195 | + // for now just emit as we did in the past |
|
| 196 | + $this->emit('\OC\Repair', 'warning', [$message]); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @param int $max |
|
| 201 | + */ |
|
| 202 | + public function startProgress($max = 0) { |
|
| 203 | + // for now just emit as we did in the past |
|
| 204 | + $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * @param int $step |
|
| 209 | + * @param string $description |
|
| 210 | + */ |
|
| 211 | + public function advance($step = 1, $description = '') { |
|
| 212 | + // for now just emit as we did in the past |
|
| 213 | + $this->emit('\OC\Repair', 'advance', [$step, $description]); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * @param int $max |
|
| 218 | + */ |
|
| 219 | + public function finishProgress() { |
|
| 220 | + // for now just emit as we did in the past |
|
| 221 | + $this->emit('\OC\Repair', 'finishProgress', []); |
|
| 222 | + } |
|
| 223 | 223 | } |
@@ -30,19 +30,19 @@ |
||
| 30 | 30 | |
| 31 | 31 | class AddCleanupUpdaterBackupsJob implements IRepairStep { |
| 32 | 32 | |
| 33 | - /** @var IJobList */ |
|
| 34 | - protected $jobList; |
|
| 33 | + /** @var IJobList */ |
|
| 34 | + protected $jobList; |
|
| 35 | 35 | |
| 36 | - public function __construct(IJobList $jobList) { |
|
| 37 | - $this->jobList = $jobList; |
|
| 38 | - } |
|
| 36 | + public function __construct(IJobList $jobList) { |
|
| 37 | + $this->jobList = $jobList; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function getName() { |
|
| 41 | - return 'Queue a one-time job to cleanup old backups of the updater'; |
|
| 42 | - } |
|
| 40 | + public function getName() { |
|
| 41 | + return 'Queue a one-time job to cleanup old backups of the updater'; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function run(IOutput $output) { |
|
| 45 | - $this->jobList->add(BackgroundCleanupUpdaterBackupsJob::class); |
|
| 46 | - } |
|
| 44 | + public function run(IOutput $output) { |
|
| 45 | + $this->jobList->add(BackgroundCleanupUpdaterBackupsJob::class); |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | |
@@ -28,63 +28,63 @@ |
||
| 28 | 28 | |
| 29 | 29 | class BackgroundCleanupUpdaterBackupsJob extends QueuedJob { |
| 30 | 30 | |
| 31 | - /** @var IConfig */ |
|
| 32 | - protected $config; |
|
| 33 | - /** @var ILogger */ |
|
| 34 | - protected $log; |
|
| 31 | + /** @var IConfig */ |
|
| 32 | + protected $config; |
|
| 33 | + /** @var ILogger */ |
|
| 34 | + protected $log; |
|
| 35 | 35 | |
| 36 | - public function __construct(IConfig $config, ILogger $log) { |
|
| 37 | - $this->config = $config; |
|
| 38 | - $this->log = $log; |
|
| 39 | - } |
|
| 36 | + public function __construct(IConfig $config, ILogger $log) { |
|
| 37 | + $this->config = $config; |
|
| 38 | + $this->log = $log; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * This job cleans up all backups except the latest 3 from the updaters backup directory |
|
| 43 | - * |
|
| 44 | - */ |
|
| 45 | - public function run($arguments) { |
|
| 46 | - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
| 47 | - $instanceId = $this->config->getSystemValue('instanceid', null); |
|
| 41 | + /** |
|
| 42 | + * This job cleans up all backups except the latest 3 from the updaters backup directory |
|
| 43 | + * |
|
| 44 | + */ |
|
| 45 | + public function run($arguments) { |
|
| 46 | + $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
| 47 | + $instanceId = $this->config->getSystemValue('instanceid', null); |
|
| 48 | 48 | |
| 49 | - if(!is_string($instanceId) || empty($instanceId)) { |
|
| 50 | - return; |
|
| 51 | - } |
|
| 49 | + if(!is_string($instanceId) || empty($instanceId)) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
| 54 | - $backupFolderPath = $updaterFolderPath . '/backups'; |
|
| 55 | - if(file_exists($backupFolderPath)) { |
|
| 56 | - $this->log->info("$backupFolderPath exists - start to clean it up"); |
|
| 53 | + $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
| 54 | + $backupFolderPath = $updaterFolderPath . '/backups'; |
|
| 55 | + if(file_exists($backupFolderPath)) { |
|
| 56 | + $this->log->info("$backupFolderPath exists - start to clean it up"); |
|
| 57 | 57 | |
| 58 | - $dirList = []; |
|
| 59 | - $dirs = new \DirectoryIterator($backupFolderPath); |
|
| 60 | - foreach($dirs as $dir) { |
|
| 61 | - // skip files and dot dirs |
|
| 62 | - if ($dir->isFile() || $dir->isDot()) { |
|
| 63 | - continue; |
|
| 64 | - } |
|
| 58 | + $dirList = []; |
|
| 59 | + $dirs = new \DirectoryIterator($backupFolderPath); |
|
| 60 | + foreach($dirs as $dir) { |
|
| 61 | + // skip files and dot dirs |
|
| 62 | + if ($dir->isFile() || $dir->isDot()) { |
|
| 63 | + continue; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $mtime = $dir->getMTime(); |
|
| 67 | - $realPath = $dir->getRealPath(); |
|
| 66 | + $mtime = $dir->getMTime(); |
|
| 67 | + $realPath = $dir->getRealPath(); |
|
| 68 | 68 | |
| 69 | - if ($realPath === false) { |
|
| 70 | - continue; |
|
| 71 | - } |
|
| 69 | + if ($realPath === false) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $dirList[$mtime] = $realPath; |
|
| 74 | - } |
|
| 73 | + $dirList[$mtime] = $realPath; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - ksort($dirList); |
|
| 77 | - // drop the newest 3 directories |
|
| 78 | - $dirList = array_slice($dirList, 0, -3); |
|
| 79 | - $this->log->info("List of all directories that will be deleted: " . json_encode($dirList)); |
|
| 76 | + ksort($dirList); |
|
| 77 | + // drop the newest 3 directories |
|
| 78 | + $dirList = array_slice($dirList, 0, -3); |
|
| 79 | + $this->log->info("List of all directories that will be deleted: " . json_encode($dirList)); |
|
| 80 | 80 | |
| 81 | - foreach($dirList as $dir) { |
|
| 82 | - $this->log->info("Removing $dir ..."); |
|
| 83 | - \OC_Helper::rmdirr($dir); |
|
| 84 | - } |
|
| 85 | - $this->log->info("Cleanup finished"); |
|
| 86 | - } else { |
|
| 87 | - $this->log->info("Could not find updater directory $backupFolderPath - cleanup step not needed"); |
|
| 88 | - } |
|
| 89 | - } |
|
| 81 | + foreach($dirList as $dir) { |
|
| 82 | + $this->log->info("Removing $dir ..."); |
|
| 83 | + \OC_Helper::rmdirr($dir); |
|
| 84 | + } |
|
| 85 | + $this->log->info("Cleanup finished"); |
|
| 86 | + } else { |
|
| 87 | + $this->log->info("Could not find updater directory $backupFolderPath - cleanup step not needed"); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -43,21 +43,21 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | 45 | public function run($arguments) { |
| 46 | - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); |
|
| 46 | + $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); |
|
| 47 | 47 | $instanceId = $this->config->getSystemValue('instanceid', null); |
| 48 | 48 | |
| 49 | - if(!is_string($instanceId) || empty($instanceId)) { |
|
| 49 | + if (!is_string($instanceId) || empty($instanceId)) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $updaterFolderPath = $dataDir . '/updater-' . $instanceId; |
|
| 54 | - $backupFolderPath = $updaterFolderPath . '/backups'; |
|
| 55 | - if(file_exists($backupFolderPath)) { |
|
| 53 | + $updaterFolderPath = $dataDir.'/updater-'.$instanceId; |
|
| 54 | + $backupFolderPath = $updaterFolderPath.'/backups'; |
|
| 55 | + if (file_exists($backupFolderPath)) { |
|
| 56 | 56 | $this->log->info("$backupFolderPath exists - start to clean it up"); |
| 57 | 57 | |
| 58 | 58 | $dirList = []; |
| 59 | 59 | $dirs = new \DirectoryIterator($backupFolderPath); |
| 60 | - foreach($dirs as $dir) { |
|
| 60 | + foreach ($dirs as $dir) { |
|
| 61 | 61 | // skip files and dot dirs |
| 62 | 62 | if ($dir->isFile() || $dir->isDot()) { |
| 63 | 63 | continue; |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | ksort($dirList); |
| 77 | 77 | // drop the newest 3 directories |
| 78 | 78 | $dirList = array_slice($dirList, 0, -3); |
| 79 | - $this->log->info("List of all directories that will be deleted: " . json_encode($dirList)); |
|
| 79 | + $this->log->info("List of all directories that will be deleted: ".json_encode($dirList)); |
|
| 80 | 80 | |
| 81 | - foreach($dirList as $dir) { |
|
| 81 | + foreach ($dirList as $dir) { |
|
| 82 | 82 | $this->log->info("Removing $dir ..."); |
| 83 | 83 | \OC_Helper::rmdirr($dir); |
| 84 | 84 | } |