Completed
Pull Request — master (#7988)
by Morris
21:04
created
lib/private/Server.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,6 @@
 block discarded – undo
103 103
 use OC\Tagging\TagMapper;
104 104
 use OC\Template\SCSSCacher;
105 105
 use OCA\Theming\ThemingDefaults;
106
-
107 106
 use OCP\App\IAppManager;
108 107
 use OCP\AppFramework\Utility\ITimeFactory;
109 108
 use OCP\Collaboration\AutoComplete\IManager;
Please login to merge, or discard this patch.
lib/private/Repair.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,6 @@
 block discarded – undo
30 30
 
31 31
 namespace OC;
32 32
 
33
-use OC\App\AppStore\Bundles\BundleFetcher;
34
-use OC\Files\AppData\Factory;
35 33
 use OC\Repair\CleanTags;
36 34
 use OC\Repair\Collation;
37 35
 use OC\Repair\MoveUpdaterStepFile;
Please login to merge, or discard this patch.
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -52,166 +52,166 @@
 block discarded – undo
52 52
 use Symfony\Component\EventDispatcher\GenericEvent;
53 53
 
54 54
 class Repair implements IOutput{
55
-	/* @var IRepairStep[] */
56
-	private $repairSteps;
57
-	/** @var EventDispatcher */
58
-	private $dispatcher;
59
-	/** @var string */
60
-	private $currentStep;
61
-
62
-	/**
63
-	 * Creates a new repair step runner
64
-	 *
65
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
66
-	 * @param EventDispatcher $dispatcher
67
-	 */
68
-	public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
69
-		$this->repairSteps = $repairSteps;
70
-		$this->dispatcher = $dispatcher;
71
-	}
72
-
73
-	/**
74
-	 * Run a series of repair steps for common problems
75
-	 */
76
-	public function run() {
77
-		if (count($this->repairSteps) === 0) {
78
-			$this->emit('\OC\Repair', 'info', array('No repair steps available'));
79
-			return;
80
-		}
81
-		// run each repair step
82
-		foreach ($this->repairSteps as $step) {
83
-			$this->currentStep = $step->getName();
84
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
85
-			$step->run($this);
86
-		}
87
-	}
88
-
89
-	/**
90
-	 * Add repair step
91
-	 *
92
-	 * @param IRepairStep|string $repairStep repair step
93
-	 * @throws \Exception
94
-	 */
95
-	public function addStep($repairStep) {
96
-		if (is_string($repairStep)) {
97
-			try {
98
-				$s = \OC::$server->query($repairStep);
99
-			} catch (QueryException $e) {
100
-				if (class_exists($repairStep)) {
101
-					$s = new $repairStep();
102
-				} else {
103
-					throw new \Exception("Repair step '$repairStep' is unknown");
104
-				}
105
-			}
106
-
107
-			if ($s instanceof IRepairStep) {
108
-				$this->repairSteps[] = $s;
109
-			} else {
110
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
111
-			}
112
-		} else {
113
-			$this->repairSteps[] = $repairStep;
114
-		}
115
-	}
116
-
117
-	/**
118
-	 * Returns the default repair steps to be run on the
119
-	 * command line or after an upgrade.
120
-	 *
121
-	 * @return IRepairStep[]
122
-	 */
123
-	public static function getRepairSteps() {
124
-		return [
125
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
126
-			new RepairMimeTypes(\OC::$server->getConfig()),
127
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
128
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
129
-			new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
130
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
131
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
132
-			new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
133
-			new AddLogRotateJob(\OC::$server->getJobList()),
134
-		];
135
-	}
136
-
137
-	/**
138
-	 * Returns expensive repair steps to be run on the
139
-	 * command line with a special option.
140
-	 *
141
-	 * @return IRepairStep[]
142
-	 */
143
-	public static function getExpensiveRepairSteps() {
144
-		return [
145
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
146
-		];
147
-	}
148
-
149
-	/**
150
-	 * Returns the repair steps to be run before an
151
-	 * upgrade.
152
-	 *
153
-	 * @return IRepairStep[]
154
-	 */
155
-	public static function getBeforeUpgradeRepairSteps() {
156
-		$connection = \OC::$server->getDatabaseConnection();
157
-		$config = \OC::$server->getConfig();
158
-		$steps = [
159
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
160
-			new SqliteAutoincrement($connection),
161
-			new SaveAccountsTableData($connection, $config),
162
-			new DropAccountTermsTable($connection),
163
-		];
164
-
165
-		return $steps;
166
-	}
167
-
168
-	/**
169
-	 * @param string $scope
170
-	 * @param string $method
171
-	 * @param array $arguments
172
-	 */
173
-	public function emit($scope, $method, array $arguments = []) {
174
-		if (!is_null($this->dispatcher)) {
175
-			$this->dispatcher->dispatch("$scope::$method",
176
-				new GenericEvent("$scope::$method", $arguments));
177
-		}
178
-	}
179
-
180
-	public function info($string) {
181
-		// for now just emit as we did in the past
182
-		$this->emit('\OC\Repair', 'info', array($string));
183
-	}
184
-
185
-	/**
186
-	 * @param string $message
187
-	 */
188
-	public function warning($message) {
189
-		// for now just emit as we did in the past
190
-		$this->emit('\OC\Repair', 'warning', [$message]);
191
-	}
192
-
193
-	/**
194
-	 * @param int $max
195
-	 */
196
-	public function startProgress($max = 0) {
197
-		// for now just emit as we did in the past
198
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
199
-	}
200
-
201
-	/**
202
-	 * @param int $step
203
-	 * @param string $description
204
-	 */
205
-	public function advance($step = 1, $description = '') {
206
-		// for now just emit as we did in the past
207
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
208
-	}
209
-
210
-	/**
211
-	 * @param int $max
212
-	 */
213
-	public function finishProgress() {
214
-		// for now just emit as we did in the past
215
-		$this->emit('\OC\Repair', 'finishProgress', []);
216
-	}
55
+    /* @var IRepairStep[] */
56
+    private $repairSteps;
57
+    /** @var EventDispatcher */
58
+    private $dispatcher;
59
+    /** @var string */
60
+    private $currentStep;
61
+
62
+    /**
63
+     * Creates a new repair step runner
64
+     *
65
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
66
+     * @param EventDispatcher $dispatcher
67
+     */
68
+    public function __construct($repairSteps = [], EventDispatcher $dispatcher = null) {
69
+        $this->repairSteps = $repairSteps;
70
+        $this->dispatcher = $dispatcher;
71
+    }
72
+
73
+    /**
74
+     * Run a series of repair steps for common problems
75
+     */
76
+    public function run() {
77
+        if (count($this->repairSteps) === 0) {
78
+            $this->emit('\OC\Repair', 'info', array('No repair steps available'));
79
+            return;
80
+        }
81
+        // run each repair step
82
+        foreach ($this->repairSteps as $step) {
83
+            $this->currentStep = $step->getName();
84
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
85
+            $step->run($this);
86
+        }
87
+    }
88
+
89
+    /**
90
+     * Add repair step
91
+     *
92
+     * @param IRepairStep|string $repairStep repair step
93
+     * @throws \Exception
94
+     */
95
+    public function addStep($repairStep) {
96
+        if (is_string($repairStep)) {
97
+            try {
98
+                $s = \OC::$server->query($repairStep);
99
+            } catch (QueryException $e) {
100
+                if (class_exists($repairStep)) {
101
+                    $s = new $repairStep();
102
+                } else {
103
+                    throw new \Exception("Repair step '$repairStep' is unknown");
104
+                }
105
+            }
106
+
107
+            if ($s instanceof IRepairStep) {
108
+                $this->repairSteps[] = $s;
109
+            } else {
110
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
111
+            }
112
+        } else {
113
+            $this->repairSteps[] = $repairStep;
114
+        }
115
+    }
116
+
117
+    /**
118
+     * Returns the default repair steps to be run on the
119
+     * command line or after an upgrade.
120
+     *
121
+     * @return IRepairStep[]
122
+     */
123
+    public static function getRepairSteps() {
124
+        return [
125
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
126
+            new RepairMimeTypes(\OC::$server->getConfig()),
127
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
128
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
129
+            new RemoveRootShares(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getLazyRootFolder()),
130
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
131
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
132
+            new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
133
+            new AddLogRotateJob(\OC::$server->getJobList()),
134
+        ];
135
+    }
136
+
137
+    /**
138
+     * Returns expensive repair steps to be run on the
139
+     * command line with a special option.
140
+     *
141
+     * @return IRepairStep[]
142
+     */
143
+    public static function getExpensiveRepairSteps() {
144
+        return [
145
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
146
+        ];
147
+    }
148
+
149
+    /**
150
+     * Returns the repair steps to be run before an
151
+     * upgrade.
152
+     *
153
+     * @return IRepairStep[]
154
+     */
155
+    public static function getBeforeUpgradeRepairSteps() {
156
+        $connection = \OC::$server->getDatabaseConnection();
157
+        $config = \OC::$server->getConfig();
158
+        $steps = [
159
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
160
+            new SqliteAutoincrement($connection),
161
+            new SaveAccountsTableData($connection, $config),
162
+            new DropAccountTermsTable($connection),
163
+        ];
164
+
165
+        return $steps;
166
+    }
167
+
168
+    /**
169
+     * @param string $scope
170
+     * @param string $method
171
+     * @param array $arguments
172
+     */
173
+    public function emit($scope, $method, array $arguments = []) {
174
+        if (!is_null($this->dispatcher)) {
175
+            $this->dispatcher->dispatch("$scope::$method",
176
+                new GenericEvent("$scope::$method", $arguments));
177
+        }
178
+    }
179
+
180
+    public function info($string) {
181
+        // for now just emit as we did in the past
182
+        $this->emit('\OC\Repair', 'info', array($string));
183
+    }
184
+
185
+    /**
186
+     * @param string $message
187
+     */
188
+    public function warning($message) {
189
+        // for now just emit as we did in the past
190
+        $this->emit('\OC\Repair', 'warning', [$message]);
191
+    }
192
+
193
+    /**
194
+     * @param int $max
195
+     */
196
+    public function startProgress($max = 0) {
197
+        // for now just emit as we did in the past
198
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
199
+    }
200
+
201
+    /**
202
+     * @param int $step
203
+     * @param string $description
204
+     */
205
+    public function advance($step = 1, $description = '') {
206
+        // for now just emit as we did in the past
207
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
208
+    }
209
+
210
+    /**
211
+     * @param int $max
212
+     */
213
+    public function finishProgress() {
214
+        // for now just emit as we did in the past
215
+        $this->emit('\OC\Repair', 'finishProgress', []);
216
+    }
217 217
 }
Please login to merge, or discard this patch.