1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2019, Morris Jobke <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @license GNU AGPL version 3 or any later version |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
11
|
|
|
* License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OC\Repair\NC16; |
24
|
|
|
|
25
|
|
|
use OC\IntegrityCheck\Checker; |
26
|
|
|
use OCP\Migration\IOutput; |
27
|
|
|
use OCP\Migration\IRepairStep; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class CleanupCypressFiles |
31
|
|
|
* |
32
|
|
|
* This repair step removes "cypress" files and folder created by viewer app in 16.0.1 |
33
|
|
|
* |
34
|
|
|
* See https://github.com/nextcloud/server/issues/16229 for more details. |
35
|
|
|
* |
36
|
|
|
* @deprecated - can be removed in 18 because this is the first version where no migration from 16 can happen |
37
|
|
|
*/ |
38
|
|
|
class RemoveCypressFiles implements IRepairStep { |
39
|
|
|
|
40
|
|
|
/** @var Checker $checker */ |
41
|
|
|
private $checker; |
42
|
|
|
|
43
|
|
|
private $pathToViewerApp = __DIR__ . '/../../../../apps/viewer'; |
44
|
|
|
|
45
|
|
|
public function getName(): string { |
46
|
|
|
return 'Cleanup cypress files from viewer app'; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function __construct(Checker $checker) { |
50
|
|
|
$this->checker = $checker; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function run(IOutput $output): void { |
54
|
|
|
$file = $this->pathToViewerApp . '/cypress.json'; |
55
|
|
|
if (file_exists($file)) { |
56
|
|
|
unlink($file); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$dir = $this->pathToViewerApp . '/cypress'; |
60
|
|
|
if (is_dir($dir)) { |
61
|
|
|
$files = new \RecursiveIteratorIterator( |
62
|
|
|
new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), |
63
|
|
|
\RecursiveIteratorIterator::CHILD_FIRST |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
foreach ($files as $fileInfo) { |
67
|
|
|
/** @var \SplFileInfo $fileInfo */ |
68
|
|
|
if ($fileInfo->isLink()) { |
69
|
|
|
unlink($fileInfo->getPathname()); |
70
|
|
|
} else if ($fileInfo->isDir()) { |
71
|
|
|
rmdir($fileInfo->getRealPath()); |
72
|
|
|
} else { |
73
|
|
|
unlink($fileInfo->getRealPath()); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
rmdir($dir); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// re-run the instance verification |
80
|
|
|
$this->checker->runInstanceVerification(); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|