Code Duplication    Length = 22-24 lines in 2 locations

lib/private/Repair/RepairMismatchFileCachePath.php 2 locations

@@ 228-251 (lines=24) @@
225
	/**
226
	 * Outputs a report about storages with wrong path that need repairing in the file cache
227
	 */
228
	private function reportAffectedStoragesParentIdWrongPath(IOutput $out) {
229
		$qb = $this->connection->getQueryBuilder();
230
		$qb->selectDistinct('fc.storage');
231
		$this->addQueryConditionsParentIdWrongPath($qb);
232
233
		// TODO: max results + paginate ?
234
		// TODO: join with oc_storages / oc_mounts to deliver user id ?
235
236
		$results = $qb->execute();
237
		$rows = $results->fetchAll();
238
		$results->closeCursor();
239
240
		$storageIds = [];
241
		foreach ($rows as $row) {
242
			$storageIds[] = $row['storage'];
243
		}
244
245
		if (!empty($storageIds)) {
246
			$out->warning('The file cache contains entries with invalid path values for the following storage numeric ids: ' . implode(' ', $storageIds));
247
			$out->warning('Please run `occ files:scan --all --repair` to repair'
248
			.'all affected storages or run `occ files:scan userid --repair for '
249
			.'each user with affected storages');
250
		}
251
	}
252
253
	/**
254
	 * Outputs a report about storages with non existing parents that need repairing in the file cache
@@ 256-277 (lines=22) @@
253
	/**
254
	 * Outputs a report about storages with non existing parents that need repairing in the file cache
255
	 */
256
	private function reportAffectedStoragesNonExistingParentIdEntry(IOutput $out) {
257
		$qb = $this->connection->getQueryBuilder();
258
		$qb->selectDistinct('fc.storage');
259
		$this->addQueryConditionsNonExistingParentIdEntry($qb);
260
261
		// TODO: max results + paginate ?
262
		// TODO: join with oc_storages / oc_mounts to deliver user id ?
263
264
		$results = $qb->execute();
265
		$rows = $results->fetchAll();
266
		$results->closeCursor();
267
268
		$storageIds = [];
269
		foreach ($rows as $row) {
270
			$storageIds[] = $row['storage'];
271
		}
272
273
		if (!empty($storageIds)) {
274
			$out->warning('The file cache contains entries where the parent id does not point to any existing entry for the following storage numeric ids: ' . implode(' ', $storageIds));
275
			$out->warning('Please run `occ files:scan --all --repair` to repair all affected storages');
276
		}
277
	}
278
279
	/**
280
	 * Repair all entries for which the parent entry exists but the path