Passed
Push — master ( c5dc9b...fc7f04 )
by Morris
29:58 queued 19:19
created
lib/private/Repair.php 1 patch
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -61,176 +61,176 @@
 block discarded – undo
61 61
 
62 62
 class Repair implements IOutput {
63 63
 
64
-	/** @var IRepairStep[] */
65
-	private $repairSteps;
66
-
67
-	/** @var EventDispatcher */
68
-	private $dispatcher;
69
-
70
-	/** @var string */
71
-	private $currentStep;
72
-
73
-	/**
74
-	 * Creates a new repair step runner
75
-	 *
76
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
77
-	 * @param EventDispatcher $dispatcher
78
-	 */
79
-	public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
80
-		$this->repairSteps = $repairSteps;
81
-		$this->dispatcher  = $dispatcher;
82
-	}
83
-
84
-	/**
85
-	 * Run a series of repair steps for common problems
86
-	 */
87
-	public function run() {
88
-		if (count($this->repairSteps) === 0) {
89
-			$this->emit('\OC\Repair', 'info', array('No repair steps available'));
90
-
91
-			return;
92
-		}
93
-		// run each repair step
94
-		foreach ($this->repairSteps as $step) {
95
-			$this->currentStep = $step->getName();
96
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
97
-			$step->run($this);
98
-		}
99
-	}
100
-
101
-	/**
102
-	 * Add repair step
103
-	 *
104
-	 * @param IRepairStep|string $repairStep repair step
105
-	 * @throws \Exception
106
-	 */
107
-	public function addStep($repairStep) {
108
-		if (is_string($repairStep)) {
109
-			try {
110
-				$s = \OC::$server->query($repairStep);
111
-			} catch (QueryException $e) {
112
-				if (class_exists($repairStep)) {
113
-					$s = new $repairStep();
114
-				} else {
115
-					throw new \Exception("Repair step '$repairStep' is unknown");
116
-				}
117
-			}
118
-
119
-			if ($s instanceof IRepairStep) {
120
-				$this->repairSteps[] = $s;
121
-			} else {
122
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
123
-			}
124
-		} else {
125
-			$this->repairSteps[] = $repairStep;
126
-		}
127
-	}
128
-
129
-	/**
130
-	 * Returns the default repair steps to be run on the
131
-	 * command line or after an upgrade.
132
-	 *
133
-	 * @return IRepairStep[]
134
-	 */
135
-	public static function getRepairSteps() {
136
-		return [
137
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
138
-			new RepairMimeTypes(\OC::$server->getConfig()),
139
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
140
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
141
-			new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
142
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
143
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
144
-			new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
145
-			new AddLogRotateJob(\OC::$server->getJobList()),
146
-			new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
147
-			new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
148
-			new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
149
-			new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
150
-			new RepairPendingCronJobs(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
151
-			new SetVcardDatabaseUID(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getLogger()),
152
-			new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
153
-		];
154
-	}
155
-
156
-	/**
157
-	 * Returns expensive repair steps to be run on the
158
-	 * command line with a special option.
159
-	 *
160
-	 * @return IRepairStep[]
161
-	 */
162
-	public static function getExpensiveRepairSteps() {
163
-		return [
164
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
165
-		];
166
-	}
167
-
168
-	/**
169
-	 * Returns the repair steps to be run before an
170
-	 * upgrade.
171
-	 *
172
-	 * @return IRepairStep[]
173
-	 */
174
-	public static function getBeforeUpgradeRepairSteps() {
175
-		$connection = \OC::$server->getDatabaseConnection();
176
-		$config     = \OC::$server->getConfig();
177
-		$steps      = [
178
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
179
-			new SqliteAutoincrement($connection),
180
-			new SaveAccountsTableData($connection, $config),
181
-			new DropAccountTermsTable($connection)
182
-		];
183
-
184
-		return $steps;
185
-	}
186
-
187
-	/**
188
-	 * @param string $scope
189
-	 * @param string $method
190
-	 * @param array $arguments
191
-	 */
192
-	public function emit($scope, $method, array $arguments = []) {
193
-		if (!is_null($this->dispatcher)) {
194
-			$this->dispatcher->dispatch("$scope::$method",
195
-				new GenericEvent("$scope::$method", $arguments));
196
-		}
197
-	}
198
-
199
-	public function info($string) {
200
-		// for now just emit as we did in the past
201
-		$this->emit('\OC\Repair', 'info', array($string));
202
-	}
203
-
204
-	/**
205
-	 * @param string $message
206
-	 */
207
-	public function warning($message) {
208
-		// for now just emit as we did in the past
209
-		$this->emit('\OC\Repair', 'warning', [$message]);
210
-	}
211
-
212
-	/**
213
-	 * @param int $max
214
-	 */
215
-	public function startProgress($max = 0) {
216
-		// for now just emit as we did in the past
217
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
218
-	}
219
-
220
-	/**
221
-	 * @param int $step
222
-	 * @param string $description
223
-	 */
224
-	public function advance($step = 1, $description = '') {
225
-		// for now just emit as we did in the past
226
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
227
-	}
228
-
229
-	/**
230
-	 * @param int $max
231
-	 */
232
-	public function finishProgress() {
233
-		// for now just emit as we did in the past
234
-		$this->emit('\OC\Repair', 'finishProgress', []);
235
-	}
64
+    /** @var IRepairStep[] */
65
+    private $repairSteps;
66
+
67
+    /** @var EventDispatcher */
68
+    private $dispatcher;
69
+
70
+    /** @var string */
71
+    private $currentStep;
72
+
73
+    /**
74
+     * Creates a new repair step runner
75
+     *
76
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
77
+     * @param EventDispatcher $dispatcher
78
+     */
79
+    public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
80
+        $this->repairSteps = $repairSteps;
81
+        $this->dispatcher  = $dispatcher;
82
+    }
83
+
84
+    /**
85
+     * Run a series of repair steps for common problems
86
+     */
87
+    public function run() {
88
+        if (count($this->repairSteps) === 0) {
89
+            $this->emit('\OC\Repair', 'info', array('No repair steps available'));
90
+
91
+            return;
92
+        }
93
+        // run each repair step
94
+        foreach ($this->repairSteps as $step) {
95
+            $this->currentStep = $step->getName();
96
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
97
+            $step->run($this);
98
+        }
99
+    }
100
+
101
+    /**
102
+     * Add repair step
103
+     *
104
+     * @param IRepairStep|string $repairStep repair step
105
+     * @throws \Exception
106
+     */
107
+    public function addStep($repairStep) {
108
+        if (is_string($repairStep)) {
109
+            try {
110
+                $s = \OC::$server->query($repairStep);
111
+            } catch (QueryException $e) {
112
+                if (class_exists($repairStep)) {
113
+                    $s = new $repairStep();
114
+                } else {
115
+                    throw new \Exception("Repair step '$repairStep' is unknown");
116
+                }
117
+            }
118
+
119
+            if ($s instanceof IRepairStep) {
120
+                $this->repairSteps[] = $s;
121
+            } else {
122
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
123
+            }
124
+        } else {
125
+            $this->repairSteps[] = $repairStep;
126
+        }
127
+    }
128
+
129
+    /**
130
+     * Returns the default repair steps to be run on the
131
+     * command line or after an upgrade.
132
+     *
133
+     * @return IRepairStep[]
134
+     */
135
+    public static function getRepairSteps() {
136
+        return [
137
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
138
+            new RepairMimeTypes(\OC::$server->getConfig()),
139
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
140
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
141
+            new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
142
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
143
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
144
+            new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
145
+            new AddLogRotateJob(\OC::$server->getJobList()),
146
+            new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
147
+            new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
148
+            new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
149
+            new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
150
+            new RepairPendingCronJobs(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
151
+            new SetVcardDatabaseUID(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getLogger()),
152
+            new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
153
+        ];
154
+    }
155
+
156
+    /**
157
+     * Returns expensive repair steps to be run on the
158
+     * command line with a special option.
159
+     *
160
+     * @return IRepairStep[]
161
+     */
162
+    public static function getExpensiveRepairSteps() {
163
+        return [
164
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
165
+        ];
166
+    }
167
+
168
+    /**
169
+     * Returns the repair steps to be run before an
170
+     * upgrade.
171
+     *
172
+     * @return IRepairStep[]
173
+     */
174
+    public static function getBeforeUpgradeRepairSteps() {
175
+        $connection = \OC::$server->getDatabaseConnection();
176
+        $config     = \OC::$server->getConfig();
177
+        $steps      = [
178
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
179
+            new SqliteAutoincrement($connection),
180
+            new SaveAccountsTableData($connection, $config),
181
+            new DropAccountTermsTable($connection)
182
+        ];
183
+
184
+        return $steps;
185
+    }
186
+
187
+    /**
188
+     * @param string $scope
189
+     * @param string $method
190
+     * @param array $arguments
191
+     */
192
+    public function emit($scope, $method, array $arguments = []) {
193
+        if (!is_null($this->dispatcher)) {
194
+            $this->dispatcher->dispatch("$scope::$method",
195
+                new GenericEvent("$scope::$method", $arguments));
196
+        }
197
+    }
198
+
199
+    public function info($string) {
200
+        // for now just emit as we did in the past
201
+        $this->emit('\OC\Repair', 'info', array($string));
202
+    }
203
+
204
+    /**
205
+     * @param string $message
206
+     */
207
+    public function warning($message) {
208
+        // for now just emit as we did in the past
209
+        $this->emit('\OC\Repair', 'warning', [$message]);
210
+    }
211
+
212
+    /**
213
+     * @param int $max
214
+     */
215
+    public function startProgress($max = 0) {
216
+        // for now just emit as we did in the past
217
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
218
+    }
219
+
220
+    /**
221
+     * @param int $step
222
+     * @param string $description
223
+     */
224
+    public function advance($step = 1, $description = '') {
225
+        // for now just emit as we did in the past
226
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
227
+    }
228
+
229
+    /**
230
+     * @param int $max
231
+     */
232
+    public function finishProgress() {
233
+        // for now just emit as we did in the past
234
+        $this->emit('\OC\Repair', 'finishProgress', []);
235
+    }
236 236
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -41,64 +41,64 @@
 block discarded – undo
41 41
  */
42 42
 class CleanupCardDAVPhotoCache implements IRepairStep {
43 43
 
44
-	/** @var IConfig */
45
-	private $config;
44
+    /** @var IConfig */
45
+    private $config;
46 46
 
47
-	/** @var IAppData */
48
-	private $appData;
47
+    /** @var IAppData */
48
+    private $appData;
49 49
 
50
-	/** @var ILogger */
51
-	private $logger;
50
+    /** @var ILogger */
51
+    private $logger;
52 52
 
53
-	public function __construct(IConfig $config, IAppData $appData, ILogger $logger) {
54
-		$this->config = $config;
55
-		$this->appData = $appData;
56
-		$this->logger = $logger;
57
-	}
53
+    public function __construct(IConfig $config, IAppData $appData, ILogger $logger) {
54
+        $this->config = $config;
55
+        $this->appData = $appData;
56
+        $this->logger = $logger;
57
+    }
58 58
 
59
-	public function getName(): string {
60
-		return 'Cleanup invalid photocache files for carddav';
61
-	}
59
+    public function getName(): string {
60
+        return 'Cleanup invalid photocache files for carddav';
61
+    }
62 62
 
63
-	private function repair(IOutput $output): void {
64
-		try {
65
-			$folders = $this->appData->getDirectoryListing();
66
-		} catch (NotFoundException $e) {
67
-			return;
68
-		}
63
+    private function repair(IOutput $output): void {
64
+        try {
65
+            $folders = $this->appData->getDirectoryListing();
66
+        } catch (NotFoundException $e) {
67
+            return;
68
+        }
69 69
 
70
-		$folders = array_filter($folders, function (ISimpleFolder $folder) {
71
-			return $folder->fileExists('photo.');
72
-		});
70
+        $folders = array_filter($folders, function (ISimpleFolder $folder) {
71
+            return $folder->fileExists('photo.');
72
+        });
73 73
 
74
-		if (empty($folders)) {
75
-			return;
76
-		}
74
+        if (empty($folders)) {
75
+            return;
76
+        }
77 77
 
78
-		$output->info('Delete ' . count($folders) . ' "photo." files');
78
+        $output->info('Delete ' . count($folders) . ' "photo." files');
79 79
 
80
-		foreach ($folders as $folder) {
81
-			try {
82
-				/** @var ISimpleFolder $folder */
83
-				$folder->getFile('photo.')->delete();
84
-			} catch (\Exception $e) {
85
-				$this->logger->logException($e);
86
-				$output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."');
87
-			}
88
-		}
89
-	}
80
+        foreach ($folders as $folder) {
81
+            try {
82
+                /** @var ISimpleFolder $folder */
83
+                $folder->getFile('photo.')->delete();
84
+            } catch (\Exception $e) {
85
+                $this->logger->logException($e);
86
+                $output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."');
87
+            }
88
+        }
89
+    }
90 90
 
91
-	private function shouldRun(): bool {
92
-		return version_compare(
93
-			$this->config->getSystemValue('version', '0.0.0.0'),
94
-			'16.0.0.0',
95
-			'<='
96
-		);
97
-	}
91
+    private function shouldRun(): bool {
92
+        return version_compare(
93
+            $this->config->getSystemValue('version', '0.0.0.0'),
94
+            '16.0.0.0',
95
+            '<='
96
+        );
97
+    }
98 98
 
99
-	public function run(IOutput $output): void {
100
-		if ($this->shouldRun()) {
101
-			$this->repair($output);
102
-		}
103
-	}
99
+    public function run(IOutput $output): void {
100
+        if ($this->shouldRun()) {
101
+            $this->repair($output);
102
+        }
103
+    }
104 104
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			return;
68 68
 		}
69 69
 
70
-		$folders = array_filter($folders, function (ISimpleFolder $folder) {
70
+		$folders = array_filter($folders, function(ISimpleFolder $folder) {
71 71
 			return $folder->fileExists('photo.');
72 72
 		});
73 73
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			return;
76 76
 		}
77 77
 
78
-		$output->info('Delete ' . count($folders) . ' "photo." files');
78
+		$output->info('Delete '.count($folders).' "photo." files');
79 79
 
80 80
 		foreach ($folders as $folder) {
81 81
 			try {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 				$folder->getFile('photo.')->delete();
84 84
 			} catch (\Exception $e) {
85 85
 				$this->logger->logException($e);
86
-				$output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."');
86
+				$output->warning('Could not delete file "dav-photocache/'.$folder->getName().'/photo."');
87 87
 			}
88 88
 		}
89 89
 	}
Please login to merge, or discard this patch.