1<?php
2/**
3 * @author Robin Appelman <icewind@owncloud.com>
4 *
5 * @copyright Copyright (c) 2018, ownCloud GmbH
6 * @license AGPL-3.0
7 *
8 * This code is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License, version 3,
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License, version 3,
18 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19 *
20 */
21
22namespace OC\Files\Cache;
23
24use OCP\Constants;
25use OCP\Files\Cache\ICache;
26
27/**
28 * Storage placeholder to represent a missing precondition, storage unavailable
29 */
30class FailedCache implements ICache {
31	/** @var bool whether to show the failed storage in the ui */
32	private $visible;
33
34	/**
35	 * FailedCache constructor.
36	 *
37	 * @param bool $visible
38	 */
39	public function __construct($visible = true) {
40		$this->visible = $visible;
41	}
42
43	public function getNumericStorageId() {
44		return -1;
45	}
46
47	public function get($file) {
48		if ($file === '') {
49			return new CacheEntry([
50				'fileid' => -1,
51				'size' => 0,
52				'mimetype' => 'httpd/unix-directory',
53				'mimepart' => 'httpd',
54				'permissions' => $this->visible ? Constants::PERMISSION_READ : 0,
55				'mtime' => \time()
56			]);
57		} else {
58			return false;
59		}
60	}
61
62	public function getFolderContents($folder) {
63		return [];
64	}
65
66	public function getFolderContentsById($fileId) {
67		return [];
68	}
69
70	public function put($file, array $data) {
71		return;
72	}
73
74	public function insert($file, array $data) {
75		return;
76	}
77
78	public function update($id, array $data) {
79		return;
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		return;
96	}
97
98	public function move($source, $target) {
99		return;
100	}
101
102	public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
103		return;
104	}
105
106	public function clear() {
107		return;
108	}
109
110	public function getStatus($file) {
111		return ICache::NOT_FOUND;
112	}
113
114	public function search($pattern) {
115		return [];
116	}
117
118	public function searchByMime($mimetype) {
119		return [];
120	}
121
122	public function searchByTag($tag, $userId) {
123		return [];
124	}
125
126	public function getAll() {
127		return [];
128	}
129
130	public function getIncomplete() {
131		return [];
132	}
133
134	public function getPathById($id) {
135		return null;
136	}
137
138	public function normalize($path) {
139		return $path;
140	}
141}
142