1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
4
|
|
|
* |
5
|
|
|
* @author Robin Appelman <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @license AGPL-3.0 |
8
|
|
|
* |
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
11
|
|
|
* as published by the Free Software Foundation. |
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, version 3, |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OC\Files\Cache; |
24
|
|
|
|
25
|
|
|
use OCP\Constants; |
26
|
|
|
use OCP\Files\Cache\ICache; |
27
|
|
|
use OCP\Files\Search\ISearchQuery; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Storage placeholder to represent a missing precondition, storage unavailable |
31
|
|
|
*/ |
32
|
|
|
class FailedCache implements ICache { |
33
|
|
|
/** @var bool whether to show the failed storage in the ui */ |
34
|
|
|
private $visible; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* FailedCache constructor. |
38
|
|
|
* |
39
|
|
|
* @param bool $visible |
40
|
|
|
*/ |
41
|
|
|
public function __construct($visible = true) { |
42
|
|
|
$this->visible = $visible; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function getNumericStorageId() { |
47
|
|
|
return -1; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function get($file) { |
51
|
|
|
if ($file === '') { |
52
|
|
|
return new CacheEntry([ |
53
|
|
|
'fileid' => -1, |
54
|
|
|
'size' => 0, |
55
|
|
|
'mimetype' => 'httpd/unix-directory', |
56
|
|
|
'mimepart' => 'httpd', |
57
|
|
|
'permissions' => $this->visible ? Constants::PERMISSION_READ : 0, |
58
|
|
|
'mtime' => time() |
59
|
|
|
]); |
60
|
|
|
} else { |
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getFolderContents($folder) { |
66
|
|
|
return []; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getFolderContentsById($fileId) { |
70
|
|
|
return []; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function put($file, array $data) { |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function insert($file, array $data) { |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function update($id, array $data) { |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getId($file) { |
83
|
|
|
return -1; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getParentId($file) { |
87
|
|
|
return -1; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function inCache($file) { |
91
|
|
|
return false; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function remove($file) { |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function move($source, $target) { |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function clear() { |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function getStatus($file) { |
107
|
|
|
return ICache::NOT_FOUND; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function search($pattern) { |
111
|
|
|
return []; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function searchByMime($mimetype) { |
115
|
|
|
return []; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function searchQuery(ISearchQuery $query) { |
119
|
|
|
return []; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getAll() { |
123
|
|
|
return []; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getIncomplete() { |
127
|
|
|
return []; |
|
|
|
|
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getPathById($id) { |
131
|
|
|
return null; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function normalize($path) { |
135
|
|
|
return $path; |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: