@@ -25,155 +25,155 @@ |
||
25 | 25 | use OCP\Files\Storage\IStorage; |
26 | 26 | |
27 | 27 | class NullStorage extends Common { |
28 | - public function __construct($parameters) { |
|
29 | - parent::__construct($parameters); |
|
30 | - } |
|
28 | + public function __construct($parameters) { |
|
29 | + parent::__construct($parameters); |
|
30 | + } |
|
31 | 31 | |
32 | - public function getId() { |
|
33 | - return 'null'; |
|
34 | - } |
|
32 | + public function getId() { |
|
33 | + return 'null'; |
|
34 | + } |
|
35 | 35 | |
36 | - public function mkdir($path) { |
|
37 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
38 | - } |
|
36 | + public function mkdir($path) { |
|
37 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
38 | + } |
|
39 | 39 | |
40 | - public function rmdir($path) { |
|
41 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
42 | - } |
|
40 | + public function rmdir($path) { |
|
41 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
42 | + } |
|
43 | 43 | |
44 | - public function opendir($path) { |
|
45 | - return new IteratorDirectory([]); |
|
46 | - } |
|
44 | + public function opendir($path) { |
|
45 | + return new IteratorDirectory([]); |
|
46 | + } |
|
47 | 47 | |
48 | - public function is_dir($path) { |
|
49 | - return $path === ''; |
|
50 | - } |
|
48 | + public function is_dir($path) { |
|
49 | + return $path === ''; |
|
50 | + } |
|
51 | 51 | |
52 | - public function is_file($path) { |
|
53 | - return false; |
|
54 | - } |
|
52 | + public function is_file($path) { |
|
53 | + return false; |
|
54 | + } |
|
55 | 55 | |
56 | - public function stat($path) { |
|
57 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
58 | - } |
|
56 | + public function stat($path) { |
|
57 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
58 | + } |
|
59 | 59 | |
60 | - public function filetype($path) { |
|
61 | - return ($path === '') ? 'dir' : false; |
|
62 | - } |
|
60 | + public function filetype($path) { |
|
61 | + return ($path === '') ? 'dir' : false; |
|
62 | + } |
|
63 | 63 | |
64 | - public function filesize($path) { |
|
65 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
66 | - } |
|
64 | + public function filesize($path) { |
|
65 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
66 | + } |
|
67 | 67 | |
68 | - public function isCreatable($path) { |
|
69 | - return false; |
|
70 | - } |
|
68 | + public function isCreatable($path) { |
|
69 | + return false; |
|
70 | + } |
|
71 | 71 | |
72 | - public function isReadable($path) { |
|
73 | - return $path === ''; |
|
74 | - } |
|
72 | + public function isReadable($path) { |
|
73 | + return $path === ''; |
|
74 | + } |
|
75 | 75 | |
76 | - public function isUpdatable($path) { |
|
77 | - return false; |
|
78 | - } |
|
76 | + public function isUpdatable($path) { |
|
77 | + return false; |
|
78 | + } |
|
79 | 79 | |
80 | - public function isDeletable($path) { |
|
81 | - return false; |
|
82 | - } |
|
80 | + public function isDeletable($path) { |
|
81 | + return false; |
|
82 | + } |
|
83 | 83 | |
84 | - public function isSharable($path) { |
|
85 | - return false; |
|
86 | - } |
|
84 | + public function isSharable($path) { |
|
85 | + return false; |
|
86 | + } |
|
87 | 87 | |
88 | - public function getPermissions($path) { |
|
89 | - return null; |
|
90 | - } |
|
88 | + public function getPermissions($path) { |
|
89 | + return null; |
|
90 | + } |
|
91 | 91 | |
92 | - public function file_exists($path) { |
|
93 | - return $path === ''; |
|
94 | - } |
|
92 | + public function file_exists($path) { |
|
93 | + return $path === ''; |
|
94 | + } |
|
95 | 95 | |
96 | - public function filemtime($path) { |
|
97 | - return ($path === '') ? time() : false; |
|
98 | - } |
|
96 | + public function filemtime($path) { |
|
97 | + return ($path === '') ? time() : false; |
|
98 | + } |
|
99 | 99 | |
100 | - public function file_get_contents($path) { |
|
101 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
102 | - } |
|
100 | + public function file_get_contents($path) { |
|
101 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
102 | + } |
|
103 | 103 | |
104 | - public function file_put_contents($path, $data) { |
|
105 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
106 | - } |
|
104 | + public function file_put_contents($path, $data) { |
|
105 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
106 | + } |
|
107 | 107 | |
108 | - public function unlink($path) { |
|
109 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
110 | - } |
|
108 | + public function unlink($path) { |
|
109 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
110 | + } |
|
111 | 111 | |
112 | - public function rename($path1, $path2) { |
|
113 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
114 | - } |
|
112 | + public function rename($path1, $path2) { |
|
113 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
114 | + } |
|
115 | 115 | |
116 | - public function copy($path1, $path2) { |
|
117 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
118 | - } |
|
116 | + public function copy($path1, $path2) { |
|
117 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
118 | + } |
|
119 | 119 | |
120 | - public function fopen($path, $mode) { |
|
121 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
122 | - } |
|
120 | + public function fopen($path, $mode) { |
|
121 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
122 | + } |
|
123 | 123 | |
124 | - public function getMimeType($path) { |
|
125 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
126 | - } |
|
124 | + public function getMimeType($path) { |
|
125 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
126 | + } |
|
127 | 127 | |
128 | - public function hash($type, $path, $raw = false) { |
|
129 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
130 | - } |
|
128 | + public function hash($type, $path, $raw = false) { |
|
129 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
130 | + } |
|
131 | 131 | |
132 | - public function free_space($path) { |
|
133 | - return FileInfo::SPACE_UNKNOWN; |
|
134 | - } |
|
132 | + public function free_space($path) { |
|
133 | + return FileInfo::SPACE_UNKNOWN; |
|
134 | + } |
|
135 | 135 | |
136 | - public function touch($path, $mtime = null) { |
|
137 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
138 | - } |
|
136 | + public function touch($path, $mtime = null) { |
|
137 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
138 | + } |
|
139 | 139 | |
140 | - public function getLocalFile($path) { |
|
141 | - return false; |
|
142 | - } |
|
140 | + public function getLocalFile($path) { |
|
141 | + return false; |
|
142 | + } |
|
143 | 143 | |
144 | - public function hasUpdated($path, $time) { |
|
145 | - return false; |
|
146 | - } |
|
144 | + public function hasUpdated($path, $time) { |
|
145 | + return false; |
|
146 | + } |
|
147 | 147 | |
148 | - public function getETag($path) { |
|
149 | - return ''; |
|
150 | - } |
|
148 | + public function getETag($path) { |
|
149 | + return ''; |
|
150 | + } |
|
151 | 151 | |
152 | - public function isLocal() { |
|
153 | - return false; |
|
154 | - } |
|
152 | + public function isLocal() { |
|
153 | + return false; |
|
154 | + } |
|
155 | 155 | |
156 | - public function getDirectDownload($path) { |
|
157 | - return false; |
|
158 | - } |
|
156 | + public function getDirectDownload($path) { |
|
157 | + return false; |
|
158 | + } |
|
159 | 159 | |
160 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { |
|
161 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
162 | - } |
|
160 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { |
|
161 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
162 | + } |
|
163 | 163 | |
164 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
165 | - throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
166 | - } |
|
164 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
165 | + throw new \OC\ForbiddenException('This request is not allowed to access the filesystem'); |
|
166 | + } |
|
167 | 167 | |
168 | - public function test() { |
|
169 | - return true; |
|
170 | - } |
|
168 | + public function test() { |
|
169 | + return true; |
|
170 | + } |
|
171 | 171 | |
172 | - public function getOwner($path) { |
|
173 | - return null; |
|
174 | - } |
|
172 | + public function getOwner($path) { |
|
173 | + return null; |
|
174 | + } |
|
175 | 175 | |
176 | - public function getCache($path = '', $storage = null) { |
|
177 | - return new NullCache(); |
|
178 | - } |
|
176 | + public function getCache($path = '', $storage = null) { |
|
177 | + return new NullCache(); |
|
178 | + } |
|
179 | 179 | } |
@@ -34,185 +34,185 @@ |
||
34 | 34 | */ |
35 | 35 | class FailedStorage extends Common { |
36 | 36 | |
37 | - /** @var \Exception */ |
|
38 | - protected $e; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param array $params ['exception' => \Exception] |
|
42 | - */ |
|
43 | - public function __construct($params) { |
|
44 | - $this->e = $params['exception']; |
|
45 | - if (!$this->e) { |
|
46 | - throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor'); |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - public function getId() { |
|
51 | - // we can't return anything sane here |
|
52 | - return 'failedstorage'; |
|
53 | - } |
|
54 | - |
|
55 | - public function mkdir($path) { |
|
56 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
57 | - } |
|
58 | - |
|
59 | - public function rmdir($path) { |
|
60 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
61 | - } |
|
62 | - |
|
63 | - public function opendir($path) { |
|
64 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
65 | - } |
|
66 | - |
|
67 | - public function is_dir($path) { |
|
68 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
69 | - } |
|
70 | - |
|
71 | - public function is_file($path) { |
|
72 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
73 | - } |
|
74 | - |
|
75 | - public function stat($path) { |
|
76 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
77 | - } |
|
78 | - |
|
79 | - public function filetype($path) { |
|
80 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
81 | - } |
|
82 | - |
|
83 | - public function filesize($path) { |
|
84 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
85 | - } |
|
86 | - |
|
87 | - public function isCreatable($path) { |
|
88 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
89 | - } |
|
90 | - |
|
91 | - public function isReadable($path) { |
|
92 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
93 | - } |
|
94 | - |
|
95 | - public function isUpdatable($path) { |
|
96 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
97 | - } |
|
98 | - |
|
99 | - public function isDeletable($path) { |
|
100 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
101 | - } |
|
102 | - |
|
103 | - public function isSharable($path) { |
|
104 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
105 | - } |
|
106 | - |
|
107 | - public function getPermissions($path) { |
|
108 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
109 | - } |
|
110 | - |
|
111 | - public function file_exists($path) { |
|
112 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
113 | - } |
|
114 | - |
|
115 | - public function filemtime($path) { |
|
116 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
117 | - } |
|
118 | - |
|
119 | - public function file_get_contents($path) { |
|
120 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
121 | - } |
|
122 | - |
|
123 | - public function file_put_contents($path, $data) { |
|
124 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
125 | - } |
|
126 | - |
|
127 | - public function unlink($path) { |
|
128 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
129 | - } |
|
130 | - |
|
131 | - public function rename($path1, $path2) { |
|
132 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
133 | - } |
|
134 | - |
|
135 | - public function copy($path1, $path2) { |
|
136 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
137 | - } |
|
138 | - |
|
139 | - public function fopen($path, $mode) { |
|
140 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
141 | - } |
|
142 | - |
|
143 | - public function getMimeType($path) { |
|
144 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
145 | - } |
|
146 | - |
|
147 | - public function hash($type, $path, $raw = false) { |
|
148 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
149 | - } |
|
150 | - |
|
151 | - public function free_space($path) { |
|
152 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
153 | - } |
|
37 | + /** @var \Exception */ |
|
38 | + protected $e; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param array $params ['exception' => \Exception] |
|
42 | + */ |
|
43 | + public function __construct($params) { |
|
44 | + $this->e = $params['exception']; |
|
45 | + if (!$this->e) { |
|
46 | + throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor'); |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + public function getId() { |
|
51 | + // we can't return anything sane here |
|
52 | + return 'failedstorage'; |
|
53 | + } |
|
54 | + |
|
55 | + public function mkdir($path) { |
|
56 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
57 | + } |
|
58 | + |
|
59 | + public function rmdir($path) { |
|
60 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
61 | + } |
|
62 | + |
|
63 | + public function opendir($path) { |
|
64 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
65 | + } |
|
66 | + |
|
67 | + public function is_dir($path) { |
|
68 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
69 | + } |
|
70 | + |
|
71 | + public function is_file($path) { |
|
72 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
73 | + } |
|
74 | + |
|
75 | + public function stat($path) { |
|
76 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
77 | + } |
|
78 | + |
|
79 | + public function filetype($path) { |
|
80 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
81 | + } |
|
82 | + |
|
83 | + public function filesize($path) { |
|
84 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
85 | + } |
|
86 | + |
|
87 | + public function isCreatable($path) { |
|
88 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
89 | + } |
|
90 | + |
|
91 | + public function isReadable($path) { |
|
92 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
93 | + } |
|
94 | + |
|
95 | + public function isUpdatable($path) { |
|
96 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
97 | + } |
|
98 | + |
|
99 | + public function isDeletable($path) { |
|
100 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
101 | + } |
|
102 | + |
|
103 | + public function isSharable($path) { |
|
104 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
105 | + } |
|
106 | + |
|
107 | + public function getPermissions($path) { |
|
108 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
109 | + } |
|
110 | + |
|
111 | + public function file_exists($path) { |
|
112 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
113 | + } |
|
114 | + |
|
115 | + public function filemtime($path) { |
|
116 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
117 | + } |
|
118 | + |
|
119 | + public function file_get_contents($path) { |
|
120 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
121 | + } |
|
122 | + |
|
123 | + public function file_put_contents($path, $data) { |
|
124 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
125 | + } |
|
126 | + |
|
127 | + public function unlink($path) { |
|
128 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
129 | + } |
|
130 | + |
|
131 | + public function rename($path1, $path2) { |
|
132 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
133 | + } |
|
134 | + |
|
135 | + public function copy($path1, $path2) { |
|
136 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
137 | + } |
|
138 | + |
|
139 | + public function fopen($path, $mode) { |
|
140 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
141 | + } |
|
142 | + |
|
143 | + public function getMimeType($path) { |
|
144 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
145 | + } |
|
146 | + |
|
147 | + public function hash($type, $path, $raw = false) { |
|
148 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
149 | + } |
|
150 | + |
|
151 | + public function free_space($path) { |
|
152 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
153 | + } |
|
154 | 154 | |
155 | - public function search($query) { |
|
156 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
157 | - } |
|
155 | + public function search($query) { |
|
156 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
157 | + } |
|
158 | 158 | |
159 | - public function touch($path, $mtime = null) { |
|
160 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
161 | - } |
|
159 | + public function touch($path, $mtime = null) { |
|
160 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
161 | + } |
|
162 | 162 | |
163 | - public function getLocalFile($path) { |
|
164 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
165 | - } |
|
163 | + public function getLocalFile($path) { |
|
164 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
165 | + } |
|
166 | 166 | |
167 | - public function getLocalFolder($path) { |
|
168 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
169 | - } |
|
167 | + public function getLocalFolder($path) { |
|
168 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
169 | + } |
|
170 | 170 | |
171 | - public function hasUpdated($path, $time) { |
|
172 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
173 | - } |
|
171 | + public function hasUpdated($path, $time) { |
|
172 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
173 | + } |
|
174 | 174 | |
175 | - public function getETag($path) { |
|
176 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
177 | - } |
|
175 | + public function getETag($path) { |
|
176 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
177 | + } |
|
178 | 178 | |
179 | - public function getDirectDownload($path) { |
|
180 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
181 | - } |
|
179 | + public function getDirectDownload($path) { |
|
180 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
181 | + } |
|
182 | 182 | |
183 | - public function verifyPath($path, $fileName) { |
|
184 | - return true; |
|
185 | - } |
|
183 | + public function verifyPath($path, $fileName) { |
|
184 | + return true; |
|
185 | + } |
|
186 | 186 | |
187 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { |
|
188 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
189 | - } |
|
187 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { |
|
188 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
189 | + } |
|
190 | 190 | |
191 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
192 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
193 | - } |
|
191 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
192 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
193 | + } |
|
194 | 194 | |
195 | - public function acquireLock($path, $type, ILockingProvider $provider) { |
|
196 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
197 | - } |
|
195 | + public function acquireLock($path, $type, ILockingProvider $provider) { |
|
196 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
197 | + } |
|
198 | 198 | |
199 | - public function releaseLock($path, $type, ILockingProvider $provider) { |
|
200 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
201 | - } |
|
199 | + public function releaseLock($path, $type, ILockingProvider $provider) { |
|
200 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
201 | + } |
|
202 | 202 | |
203 | - public function changeLock($path, $type, ILockingProvider $provider) { |
|
204 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
205 | - } |
|
203 | + public function changeLock($path, $type, ILockingProvider $provider) { |
|
204 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
205 | + } |
|
206 | 206 | |
207 | - public function getAvailability() { |
|
208 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
209 | - } |
|
207 | + public function getAvailability() { |
|
208 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
209 | + } |
|
210 | 210 | |
211 | - public function setAvailability($isAvailable) { |
|
212 | - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
213 | - } |
|
211 | + public function setAvailability($isAvailable) { |
|
212 | + throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); |
|
213 | + } |
|
214 | 214 | |
215 | - public function getCache($path = '', $storage = null) { |
|
216 | - return new FailedCache(); |
|
217 | - } |
|
215 | + public function getCache($path = '', $storage = null) { |
|
216 | + return new FailedCache(); |
|
217 | + } |
|
218 | 218 | } |
@@ -32,128 +32,128 @@ |
||
32 | 32 | use Symfony\Component\Routing\Route as SymfonyRoute; |
33 | 33 | |
34 | 34 | class Route extends SymfonyRoute implements IRoute { |
35 | - /** |
|
36 | - * Specify the method when this route is to be used |
|
37 | - * |
|
38 | - * @param string $method HTTP method (uppercase) |
|
39 | - * @return \OC\Route\Route |
|
40 | - */ |
|
41 | - public function method($method) { |
|
42 | - $this->setMethods($method); |
|
43 | - return $this; |
|
44 | - } |
|
35 | + /** |
|
36 | + * Specify the method when this route is to be used |
|
37 | + * |
|
38 | + * @param string $method HTTP method (uppercase) |
|
39 | + * @return \OC\Route\Route |
|
40 | + */ |
|
41 | + public function method($method) { |
|
42 | + $this->setMethods($method); |
|
43 | + return $this; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Specify POST as the method to use with this route |
|
48 | - * @return \OC\Route\Route |
|
49 | - */ |
|
50 | - public function post() { |
|
51 | - $this->method('POST'); |
|
52 | - return $this; |
|
53 | - } |
|
46 | + /** |
|
47 | + * Specify POST as the method to use with this route |
|
48 | + * @return \OC\Route\Route |
|
49 | + */ |
|
50 | + public function post() { |
|
51 | + $this->method('POST'); |
|
52 | + return $this; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Specify GET as the method to use with this route |
|
57 | - * @return \OC\Route\Route |
|
58 | - */ |
|
59 | - public function get() { |
|
60 | - $this->method('GET'); |
|
61 | - return $this; |
|
62 | - } |
|
55 | + /** |
|
56 | + * Specify GET as the method to use with this route |
|
57 | + * @return \OC\Route\Route |
|
58 | + */ |
|
59 | + public function get() { |
|
60 | + $this->method('GET'); |
|
61 | + return $this; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Specify PUT as the method to use with this route |
|
66 | - * @return \OC\Route\Route |
|
67 | - */ |
|
68 | - public function put() { |
|
69 | - $this->method('PUT'); |
|
70 | - return $this; |
|
71 | - } |
|
64 | + /** |
|
65 | + * Specify PUT as the method to use with this route |
|
66 | + * @return \OC\Route\Route |
|
67 | + */ |
|
68 | + public function put() { |
|
69 | + $this->method('PUT'); |
|
70 | + return $this; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Specify DELETE as the method to use with this route |
|
75 | - * @return \OC\Route\Route |
|
76 | - */ |
|
77 | - public function delete() { |
|
78 | - $this->method('DELETE'); |
|
79 | - return $this; |
|
80 | - } |
|
73 | + /** |
|
74 | + * Specify DELETE as the method to use with this route |
|
75 | + * @return \OC\Route\Route |
|
76 | + */ |
|
77 | + public function delete() { |
|
78 | + $this->method('DELETE'); |
|
79 | + return $this; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Specify PATCH as the method to use with this route |
|
84 | - * @return \OC\Route\Route |
|
85 | - */ |
|
86 | - public function patch() { |
|
87 | - $this->method('PATCH'); |
|
88 | - return $this; |
|
89 | - } |
|
82 | + /** |
|
83 | + * Specify PATCH as the method to use with this route |
|
84 | + * @return \OC\Route\Route |
|
85 | + */ |
|
86 | + public function patch() { |
|
87 | + $this->method('PATCH'); |
|
88 | + return $this; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Defaults to use for this route |
|
93 | - * |
|
94 | - * @param array $defaults The defaults |
|
95 | - * @return \OC\Route\Route |
|
96 | - */ |
|
97 | - public function defaults($defaults) { |
|
98 | - $action = $this->getDefault('action'); |
|
99 | - $this->setDefaults($defaults); |
|
100 | - if (isset($defaults['action'])) { |
|
101 | - $action = $defaults['action']; |
|
102 | - } |
|
103 | - $this->action($action); |
|
104 | - return $this; |
|
105 | - } |
|
91 | + /** |
|
92 | + * Defaults to use for this route |
|
93 | + * |
|
94 | + * @param array $defaults The defaults |
|
95 | + * @return \OC\Route\Route |
|
96 | + */ |
|
97 | + public function defaults($defaults) { |
|
98 | + $action = $this->getDefault('action'); |
|
99 | + $this->setDefaults($defaults); |
|
100 | + if (isset($defaults['action'])) { |
|
101 | + $action = $defaults['action']; |
|
102 | + } |
|
103 | + $this->action($action); |
|
104 | + return $this; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Requirements for this route |
|
109 | - * |
|
110 | - * @param array $requirements The requirements |
|
111 | - * @return \OC\Route\Route |
|
112 | - */ |
|
113 | - public function requirements($requirements) { |
|
114 | - $method = $this->getMethods(); |
|
115 | - $this->setRequirements($requirements); |
|
116 | - if (isset($requirements['_method'])) { |
|
117 | - $method = $requirements['_method']; |
|
118 | - } |
|
119 | - if ($method) { |
|
120 | - $this->method($method); |
|
121 | - } |
|
122 | - return $this; |
|
123 | - } |
|
107 | + /** |
|
108 | + * Requirements for this route |
|
109 | + * |
|
110 | + * @param array $requirements The requirements |
|
111 | + * @return \OC\Route\Route |
|
112 | + */ |
|
113 | + public function requirements($requirements) { |
|
114 | + $method = $this->getMethods(); |
|
115 | + $this->setRequirements($requirements); |
|
116 | + if (isset($requirements['_method'])) { |
|
117 | + $method = $requirements['_method']; |
|
118 | + } |
|
119 | + if ($method) { |
|
120 | + $this->method($method); |
|
121 | + } |
|
122 | + return $this; |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * The action to execute when this route matches |
|
127 | - * |
|
128 | - * @param string|callable $class the class or a callable |
|
129 | - * @param string $function the function to use with the class |
|
130 | - * @return \OC\Route\Route |
|
131 | - * |
|
132 | - * This function is called with $class set to a callable or |
|
133 | - * to the class with $function |
|
134 | - */ |
|
135 | - public function action($class, $function = null) { |
|
136 | - $action = array($class, $function); |
|
137 | - if (is_null($function)) { |
|
138 | - $action = $class; |
|
139 | - } |
|
140 | - $this->setDefault('action', $action); |
|
141 | - return $this; |
|
142 | - } |
|
125 | + /** |
|
126 | + * The action to execute when this route matches |
|
127 | + * |
|
128 | + * @param string|callable $class the class or a callable |
|
129 | + * @param string $function the function to use with the class |
|
130 | + * @return \OC\Route\Route |
|
131 | + * |
|
132 | + * This function is called with $class set to a callable or |
|
133 | + * to the class with $function |
|
134 | + */ |
|
135 | + public function action($class, $function = null) { |
|
136 | + $action = array($class, $function); |
|
137 | + if (is_null($function)) { |
|
138 | + $action = $class; |
|
139 | + } |
|
140 | + $this->setDefault('action', $action); |
|
141 | + return $this; |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * The action to execute when this route matches, includes a file like |
|
146 | - * it is called directly |
|
147 | - * @param string $file |
|
148 | - * @return void |
|
149 | - */ |
|
150 | - public function actionInclude($file) { |
|
151 | - $function = function($param) use ($file) { |
|
152 | - unset($param["_route"]); |
|
153 | - $_GET=array_merge($_GET, $param); |
|
154 | - unset($param); |
|
155 | - require_once "$file"; |
|
156 | - } ; |
|
157 | - $this->action($function); |
|
158 | - } |
|
144 | + /** |
|
145 | + * The action to execute when this route matches, includes a file like |
|
146 | + * it is called directly |
|
147 | + * @param string $file |
|
148 | + * @return void |
|
149 | + */ |
|
150 | + public function actionInclude($file) { |
|
151 | + $function = function($param) use ($file) { |
|
152 | + unset($param["_route"]); |
|
153 | + $_GET=array_merge($_GET, $param); |
|
154 | + unset($param); |
|
155 | + require_once "$file"; |
|
156 | + } ; |
|
157 | + $this->action($function); |
|
158 | + } |
|
159 | 159 | } |
@@ -150,7 +150,7 @@ |
||
150 | 150 | public function actionInclude($file) { |
151 | 151 | $function = function($param) use ($file) { |
152 | 152 | unset($param["_route"]); |
153 | - $_GET=array_merge($_GET, $param); |
|
153 | + $_GET = array_merge($_GET, $param); |
|
154 | 154 | unset($param); |
155 | 155 | require_once "$file"; |
156 | 156 | } ; |
@@ -13,74 +13,74 @@ |
||
13 | 13 | use OCP\Share\IManager; |
14 | 14 | |
15 | 15 | class ShareInfoMiddleware extends Middleware { |
16 | - /** @var IManager */ |
|
17 | - private $shareManager; |
|
16 | + /** @var IManager */ |
|
17 | + private $shareManager; |
|
18 | 18 | |
19 | - public function __construct(IManager $shareManager) { |
|
20 | - $this->shareManager = $shareManager; |
|
21 | - } |
|
19 | + public function __construct(IManager $shareManager) { |
|
20 | + $this->shareManager = $shareManager; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param Controller $controller |
|
25 | - * @param string $methodName |
|
26 | - * @throws S2SException |
|
27 | - */ |
|
28 | - public function beforeController($controller, $methodName) { |
|
29 | - if (!($controller instanceof ShareInfoController)) { |
|
30 | - return; |
|
31 | - } |
|
23 | + /** |
|
24 | + * @param Controller $controller |
|
25 | + * @param string $methodName |
|
26 | + * @throws S2SException |
|
27 | + */ |
|
28 | + public function beforeController($controller, $methodName) { |
|
29 | + if (!($controller instanceof ShareInfoController)) { |
|
30 | + return; |
|
31 | + } |
|
32 | 32 | |
33 | - if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { |
|
34 | - throw new S2SException(); |
|
35 | - } |
|
36 | - } |
|
33 | + if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { |
|
34 | + throw new S2SException(); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param Controller $controller |
|
40 | - * @param string $methodName |
|
41 | - * @param \Exception $exception |
|
42 | - * @throws \Exception |
|
43 | - * @return Response |
|
44 | - */ |
|
45 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
46 | - if (!($controller instanceof ShareInfoController)) { |
|
47 | - throw $exception; |
|
48 | - } |
|
38 | + /** |
|
39 | + * @param Controller $controller |
|
40 | + * @param string $methodName |
|
41 | + * @param \Exception $exception |
|
42 | + * @throws \Exception |
|
43 | + * @return Response |
|
44 | + */ |
|
45 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
46 | + if (!($controller instanceof ShareInfoController)) { |
|
47 | + throw $exception; |
|
48 | + } |
|
49 | 49 | |
50 | - if ($exception instanceof S2SException) { |
|
51 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
52 | - } |
|
50 | + if ($exception instanceof S2SException) { |
|
51 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
52 | + } |
|
53 | 53 | |
54 | - throw $exception; |
|
55 | - } |
|
54 | + throw $exception; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param Controller $controller |
|
59 | - * @param string $methodName |
|
60 | - * @param Response $response |
|
61 | - * @return Response |
|
62 | - */ |
|
63 | - public function afterController($controller, $methodName, Response $response) { |
|
64 | - if (!($controller instanceof ShareInfoController)) { |
|
65 | - return $response; |
|
66 | - } |
|
57 | + /** |
|
58 | + * @param Controller $controller |
|
59 | + * @param string $methodName |
|
60 | + * @param Response $response |
|
61 | + * @return Response |
|
62 | + */ |
|
63 | + public function afterController($controller, $methodName, Response $response) { |
|
64 | + if (!($controller instanceof ShareInfoController)) { |
|
65 | + return $response; |
|
66 | + } |
|
67 | 67 | |
68 | - if (!($response instanceof JSONResponse)) { |
|
69 | - return $response; |
|
70 | - } |
|
68 | + if (!($response instanceof JSONResponse)) { |
|
69 | + return $response; |
|
70 | + } |
|
71 | 71 | |
72 | - $data = $response->getData(); |
|
73 | - $status = 'error'; |
|
72 | + $data = $response->getData(); |
|
73 | + $status = 'error'; |
|
74 | 74 | |
75 | - if ($response->getStatus() === Http::STATUS_OK) { |
|
76 | - $status = 'success'; |
|
77 | - } |
|
75 | + if ($response->getStatus() === Http::STATUS_OK) { |
|
76 | + $status = 'success'; |
|
77 | + } |
|
78 | 78 | |
79 | - $response->setData([ |
|
80 | - 'data' => $data, |
|
81 | - 'status' => $status, |
|
82 | - ]); |
|
79 | + $response->setData([ |
|
80 | + 'data' => $data, |
|
81 | + 'status' => $status, |
|
82 | + ]); |
|
83 | 83 | |
84 | - return $response; |
|
85 | - } |
|
84 | + return $response; |
|
85 | + } |
|
86 | 86 | } |
@@ -17,114 +17,114 @@ |
||
17 | 17 | |
18 | 18 | class ShareInfoController extends ApiController { |
19 | 19 | |
20 | - /** @var IManager */ |
|
21 | - private $shareManager; |
|
22 | - |
|
23 | - /** |
|
24 | - * ShareInfoController constructor. |
|
25 | - * |
|
26 | - * @param string $appName |
|
27 | - * @param IRequest $request |
|
28 | - * @param IManager $shareManager |
|
29 | - */ |
|
30 | - public function __construct($appName, |
|
31 | - IRequest $request, |
|
32 | - IManager $shareManager) { |
|
33 | - parent::__construct($appName, $request); |
|
34 | - |
|
35 | - $this->shareManager = $shareManager; |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @PublicPage |
|
40 | - * @NoCSRFRequired |
|
41 | - * |
|
42 | - * @param string $t |
|
43 | - * @param null $password |
|
44 | - * @param null $dir |
|
45 | - * @return JSONResponse |
|
46 | - * @throws ShareNotFound |
|
47 | - */ |
|
48 | - public function info($t, $password = null, $dir = null) { |
|
49 | - try { |
|
50 | - $share = $this->shareManager->getShareByToken($t); |
|
51 | - } catch (ShareNotFound $e) { |
|
52 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
53 | - } |
|
54 | - |
|
55 | - if ($share->getPassword() && !$this->shareManager->checkPassword($share, $password)) { |
|
56 | - return new JSONResponse([], Http::STATUS_FORBIDDEN); |
|
57 | - } |
|
58 | - |
|
59 | - if (!($share->getPermissions() & Constants::PERMISSION_READ)) { |
|
60 | - return new JSONResponse([], Http::STATUS_FORBIDDEN); |
|
61 | - } |
|
62 | - |
|
63 | - $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); |
|
64 | - if (!$isWritable) { |
|
65 | - $this->addROWrapper(); |
|
66 | - } |
|
67 | - |
|
68 | - $node = $share->getNode(); |
|
69 | - |
|
70 | - if ($dir !== null && $node instanceof Folder) { |
|
71 | - try { |
|
72 | - $node = $node->get($dir); |
|
73 | - } catch (NotFoundException $e) { |
|
74 | - |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - return new JSONResponse($this->parseNode($node)); |
|
79 | - } |
|
80 | - |
|
81 | - private function parseNode(Node $node) { |
|
82 | - if ($node instanceof File) { |
|
83 | - return $this->parseFile($node); |
|
84 | - } |
|
85 | - return $this->parseFolder($node); |
|
86 | - } |
|
87 | - |
|
88 | - private function parseFile(File $file) { |
|
89 | - return $this->format($file); |
|
90 | - } |
|
91 | - |
|
92 | - private function parseFolder(Folder $folder) { |
|
93 | - $data = $this->format($folder); |
|
94 | - |
|
95 | - $data['children'] = []; |
|
96 | - |
|
97 | - $nodes = $folder->getDirectoryListing(); |
|
98 | - foreach ($nodes as $node) { |
|
99 | - $data['children'][] = $this->parseNode($node); |
|
100 | - } |
|
101 | - |
|
102 | - return $data; |
|
103 | - } |
|
104 | - |
|
105 | - private function format(Node $node) { |
|
106 | - $entry = []; |
|
107 | - |
|
108 | - $entry['id'] = $node->getId(); |
|
109 | - $entry['parentId'] = $node->getParent()->getId(); |
|
110 | - $entry['mtime'] = $node->getMTime(); |
|
111 | - |
|
112 | - $entry['name'] = $node->getName(); |
|
113 | - $entry['permissions'] = $node->getPermissions(); |
|
114 | - $entry['mimetype'] = $node->getMimetype(); |
|
115 | - $entry['size'] = $node->getSize(); |
|
116 | - $entry['type'] = $node->getType(); |
|
117 | - $entry['etag'] = $node->getEtag(); |
|
118 | - |
|
119 | - return $entry; |
|
120 | - } |
|
121 | - |
|
122 | - protected function addROWrapper() { |
|
123 | - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
124 | - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
125 | - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
126 | - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
|
127 | - }); |
|
128 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
129 | - } |
|
20 | + /** @var IManager */ |
|
21 | + private $shareManager; |
|
22 | + |
|
23 | + /** |
|
24 | + * ShareInfoController constructor. |
|
25 | + * |
|
26 | + * @param string $appName |
|
27 | + * @param IRequest $request |
|
28 | + * @param IManager $shareManager |
|
29 | + */ |
|
30 | + public function __construct($appName, |
|
31 | + IRequest $request, |
|
32 | + IManager $shareManager) { |
|
33 | + parent::__construct($appName, $request); |
|
34 | + |
|
35 | + $this->shareManager = $shareManager; |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @PublicPage |
|
40 | + * @NoCSRFRequired |
|
41 | + * |
|
42 | + * @param string $t |
|
43 | + * @param null $password |
|
44 | + * @param null $dir |
|
45 | + * @return JSONResponse |
|
46 | + * @throws ShareNotFound |
|
47 | + */ |
|
48 | + public function info($t, $password = null, $dir = null) { |
|
49 | + try { |
|
50 | + $share = $this->shareManager->getShareByToken($t); |
|
51 | + } catch (ShareNotFound $e) { |
|
52 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
53 | + } |
|
54 | + |
|
55 | + if ($share->getPassword() && !$this->shareManager->checkPassword($share, $password)) { |
|
56 | + return new JSONResponse([], Http::STATUS_FORBIDDEN); |
|
57 | + } |
|
58 | + |
|
59 | + if (!($share->getPermissions() & Constants::PERMISSION_READ)) { |
|
60 | + return new JSONResponse([], Http::STATUS_FORBIDDEN); |
|
61 | + } |
|
62 | + |
|
63 | + $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); |
|
64 | + if (!$isWritable) { |
|
65 | + $this->addROWrapper(); |
|
66 | + } |
|
67 | + |
|
68 | + $node = $share->getNode(); |
|
69 | + |
|
70 | + if ($dir !== null && $node instanceof Folder) { |
|
71 | + try { |
|
72 | + $node = $node->get($dir); |
|
73 | + } catch (NotFoundException $e) { |
|
74 | + |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + return new JSONResponse($this->parseNode($node)); |
|
79 | + } |
|
80 | + |
|
81 | + private function parseNode(Node $node) { |
|
82 | + if ($node instanceof File) { |
|
83 | + return $this->parseFile($node); |
|
84 | + } |
|
85 | + return $this->parseFolder($node); |
|
86 | + } |
|
87 | + |
|
88 | + private function parseFile(File $file) { |
|
89 | + return $this->format($file); |
|
90 | + } |
|
91 | + |
|
92 | + private function parseFolder(Folder $folder) { |
|
93 | + $data = $this->format($folder); |
|
94 | + |
|
95 | + $data['children'] = []; |
|
96 | + |
|
97 | + $nodes = $folder->getDirectoryListing(); |
|
98 | + foreach ($nodes as $node) { |
|
99 | + $data['children'][] = $this->parseNode($node); |
|
100 | + } |
|
101 | + |
|
102 | + return $data; |
|
103 | + } |
|
104 | + |
|
105 | + private function format(Node $node) { |
|
106 | + $entry = []; |
|
107 | + |
|
108 | + $entry['id'] = $node->getId(); |
|
109 | + $entry['parentId'] = $node->getParent()->getId(); |
|
110 | + $entry['mtime'] = $node->getMTime(); |
|
111 | + |
|
112 | + $entry['name'] = $node->getName(); |
|
113 | + $entry['permissions'] = $node->getPermissions(); |
|
114 | + $entry['mimetype'] = $node->getMimetype(); |
|
115 | + $entry['size'] = $node->getSize(); |
|
116 | + $entry['type'] = $node->getType(); |
|
117 | + $entry['etag'] = $node->getEtag(); |
|
118 | + |
|
119 | + return $entry; |
|
120 | + } |
|
121 | + |
|
122 | + protected function addROWrapper() { |
|
123 | + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
|
124 | + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
125 | + \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
126 | + return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
|
127 | + }); |
|
128 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
|
129 | + } |
|
130 | 130 | } |
@@ -122,7 +122,7 @@ |
||
122 | 122 | protected function addROWrapper() { |
123 | 123 | // FIXME: should not add storage wrappers outside of preSetup, need to find a better way |
124 | 124 | $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
125 | - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { |
|
125 | + \OC\Files\Filesystem::addStorageWrapper('readonly', function($mountPoint, $storage) { |
|
126 | 126 | return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); |
127 | 127 | }); |
128 | 128 | \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); |
@@ -29,32 +29,32 @@ |
||
29 | 29 | |
30 | 30 | class DropAccountTermsTable implements IRepairStep { |
31 | 31 | |
32 | - /** @var IDBConnection */ |
|
33 | - protected $db; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param IDBConnection $db |
|
37 | - */ |
|
38 | - public function __construct(IDBConnection $db) { |
|
39 | - $this->db = $db; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function getName() { |
|
46 | - return 'Drop account terms table when migrating from ownCloud'; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IOutput $output |
|
51 | - */ |
|
52 | - public function run(IOutput $output) { |
|
53 | - if (!$this->db->tableExists('account_terms')) { |
|
54 | - return; |
|
55 | - } |
|
56 | - |
|
57 | - $this->db->dropTable('account_terms'); |
|
58 | - } |
|
32 | + /** @var IDBConnection */ |
|
33 | + protected $db; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param IDBConnection $db |
|
37 | + */ |
|
38 | + public function __construct(IDBConnection $db) { |
|
39 | + $this->db = $db; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function getName() { |
|
46 | + return 'Drop account terms table when migrating from ownCloud'; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IOutput $output |
|
51 | + */ |
|
52 | + public function run(IOutput $output) { |
|
53 | + if (!$this->db->tableExists('account_terms')) { |
|
54 | + return; |
|
55 | + } |
|
56 | + |
|
57 | + $this->db->dropTable('account_terms'); |
|
58 | + } |
|
59 | 59 | } |
60 | 60 |
@@ -29,48 +29,48 @@ |
||
29 | 29 | */ |
30 | 30 | class ExpireSharesJob extends TimedJob { |
31 | 31 | |
32 | - /** |
|
33 | - * sets the correct interval for this timed job |
|
34 | - */ |
|
35 | - public function __construct() { |
|
36 | - // Run once a day |
|
37 | - $this->setInterval(24 * 60 * 60); |
|
38 | - } |
|
32 | + /** |
|
33 | + * sets the correct interval for this timed job |
|
34 | + */ |
|
35 | + public function __construct() { |
|
36 | + // Run once a day |
|
37 | + $this->setInterval(24 * 60 * 60); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Makes the background job do its work |
|
42 | - * |
|
43 | - * @param array $argument unused argument |
|
44 | - */ |
|
45 | - public function run($argument) { |
|
46 | - $connection = \OC::$server->getDatabaseConnection(); |
|
40 | + /** |
|
41 | + * Makes the background job do its work |
|
42 | + * |
|
43 | + * @param array $argument unused argument |
|
44 | + */ |
|
45 | + public function run($argument) { |
|
46 | + $connection = \OC::$server->getDatabaseConnection(); |
|
47 | 47 | |
48 | - //Current time |
|
49 | - $now = new \DateTime(); |
|
50 | - $now = $now->format('Y-m-d H:i:s'); |
|
48 | + //Current time |
|
49 | + $now = new \DateTime(); |
|
50 | + $now = $now->format('Y-m-d H:i:s'); |
|
51 | 51 | |
52 | - /* |
|
52 | + /* |
|
53 | 53 | * Expire file link shares only (for now) |
54 | 54 | */ |
55 | - $qb = $connection->getQueryBuilder(); |
|
56 | - $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
57 | - ->from('share') |
|
58 | - ->where( |
|
59 | - $qb->expr()->andX( |
|
60 | - $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), |
|
61 | - $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
62 | - $qb->expr()->orX( |
|
63 | - $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
64 | - $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
65 | - ) |
|
66 | - ) |
|
67 | - ); |
|
55 | + $qb = $connection->getQueryBuilder(); |
|
56 | + $qb->select('id', 'file_source', 'uid_owner', 'item_type') |
|
57 | + ->from('share') |
|
58 | + ->where( |
|
59 | + $qb->expr()->andX( |
|
60 | + $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), |
|
61 | + $qb->expr()->lte('expiration', $qb->expr()->literal($now)), |
|
62 | + $qb->expr()->orX( |
|
63 | + $qb->expr()->eq('item_type', $qb->expr()->literal('file')), |
|
64 | + $qb->expr()->eq('item_type', $qb->expr()->literal('folder')) |
|
65 | + ) |
|
66 | + ) |
|
67 | + ); |
|
68 | 68 | |
69 | - $shares = $qb->execute(); |
|
70 | - while($share = $shares->fetch()) { |
|
71 | - \OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
|
72 | - } |
|
73 | - $shares->closeCursor(); |
|
74 | - } |
|
69 | + $shares = $qb->execute(); |
|
70 | + while($share = $shares->fetch()) { |
|
71 | + \OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
|
72 | + } |
|
73 | + $shares->closeCursor(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | $shares = $qb->execute(); |
70 | - while($share = $shares->fetch()) { |
|
70 | + while ($share = $shares->fetch()) { |
|
71 | 71 | \OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); |
72 | 72 | } |
73 | 73 | $shares->closeCursor(); |
@@ -27,18 +27,18 @@ |
||
27 | 27 | */ |
28 | 28 | class InvalidAuth extends AuthMechanism { |
29 | 29 | |
30 | - /** |
|
31 | - * Constructs a new InvalidAuth with the id of the invalid auth |
|
32 | - * for display purposes |
|
33 | - * |
|
34 | - * @param string $invalidId invalid id |
|
35 | - */ |
|
36 | - public function __construct($invalidId) { |
|
37 | - $this |
|
38 | - ->setIdentifier($invalidId) |
|
39 | - ->setScheme(self::SCHEME_NULL) |
|
40 | - ->setText('Unknown auth mechanism backend ' . $invalidId) |
|
41 | - ; |
|
42 | - } |
|
30 | + /** |
|
31 | + * Constructs a new InvalidAuth with the id of the invalid auth |
|
32 | + * for display purposes |
|
33 | + * |
|
34 | + * @param string $invalidId invalid id |
|
35 | + */ |
|
36 | + public function __construct($invalidId) { |
|
37 | + $this |
|
38 | + ->setIdentifier($invalidId) |
|
39 | + ->setScheme(self::SCHEME_NULL) |
|
40 | + ->setText('Unknown auth mechanism backend ' . $invalidId) |
|
41 | + ; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | $this |
38 | 38 | ->setIdentifier($invalidId) |
39 | 39 | ->setScheme(self::SCHEME_NULL) |
40 | - ->setText('Unknown auth mechanism backend ' . $invalidId) |
|
40 | + ->setText('Unknown auth mechanism backend '.$invalidId) |
|
41 | 41 | ; |
42 | 42 | } |
43 | 43 |
@@ -26,20 +26,20 @@ |
||
26 | 26 | |
27 | 27 | interface IGroupLDAP { |
28 | 28 | |
29 | - //Used by LDAPProvider |
|
29 | + //Used by LDAPProvider |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return access for LDAP interaction. |
|
33 | - * @param string $gid |
|
34 | - * @return Access instance of Access for LDAP interaction |
|
35 | - */ |
|
36 | - public function getLDAPAccess($gid); |
|
31 | + /** |
|
32 | + * Return access for LDAP interaction. |
|
33 | + * @param string $gid |
|
34 | + * @return Access instance of Access for LDAP interaction |
|
35 | + */ |
|
36 | + public function getLDAPAccess($gid); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Return a new LDAP connection for the specified group. |
|
40 | - * @param string $gid |
|
41 | - * @return resource of the LDAP connection |
|
42 | - */ |
|
43 | - public function getNewLDAPConnection($gid); |
|
38 | + /** |
|
39 | + * Return a new LDAP connection for the specified group. |
|
40 | + * @param string $gid |
|
41 | + * @return resource of the LDAP connection |
|
42 | + */ |
|
43 | + public function getNewLDAPConnection($gid); |
|
44 | 44 | |
45 | 45 | } |