|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright 2018, Roeland Jago Douma <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU AGPL version 3 or any later version |
|
9
|
|
|
* |
|
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
13
|
|
|
* License, or (at your option) any later version. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU Affero General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace OCA\Files_Versions\Sabre; |
|
26
|
|
|
|
|
27
|
|
|
use Sabre\DAV\Exception\Forbidden; |
|
28
|
|
|
use Sabre\DAV\ICollection; |
|
29
|
|
|
use Sabre\DAV\IMoveTarget; |
|
30
|
|
|
use Sabre\DAV\INode; |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
View Code Duplication |
class RestoreFolder implements ICollection, IMoveTarget { |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** @var string */ |
|
36
|
|
|
protected $userId; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct(string $userId) { |
|
39
|
|
|
$this->userId = $userId; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function createFile($name, $data = null) { |
|
43
|
|
|
throw new Forbidden(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function createDirectory($name) { |
|
47
|
|
|
throw new Forbidden(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getChild($name) { |
|
51
|
|
|
return null; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function delete() { |
|
55
|
|
|
throw new Forbidden(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getName() { |
|
59
|
|
|
return 'restore'; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function setName($name) { |
|
63
|
|
|
throw new Forbidden(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getLastModified(): int { |
|
67
|
|
|
return 0; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getChildren(): array { |
|
71
|
|
|
return []; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function childExists($name): bool { |
|
75
|
|
|
return false; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
79
|
|
|
if (!($sourceNode instanceof VersionFile)) { |
|
80
|
|
|
return false; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $sourceNode->rollBack(); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.