@@ -29,193 +29,193 @@ |
||
29 | 29 | use OCP\Files\SimpleFS\ISimpleFile; |
30 | 30 | |
31 | 31 | class NewSimpleFile implements ISimpleFile { |
32 | - private $parentFolder; |
|
33 | - private $name; |
|
34 | - /** @var File|null */ |
|
35 | - private $file = null; |
|
36 | - |
|
37 | - /** |
|
38 | - * File constructor. |
|
39 | - * |
|
40 | - * @param File $file |
|
41 | - */ |
|
42 | - public function __construct(Folder $parentFolder, string $name) { |
|
43 | - $this->parentFolder = $parentFolder; |
|
44 | - $this->name = $name; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Get the name |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->name; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Get the size in bytes |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function getSize() { |
|
62 | - if ($this->file) { |
|
63 | - return $this->file->getSize(); |
|
64 | - } else { |
|
65 | - return 0; |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Get the ETag |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getETag() { |
|
75 | - if ($this->file) { |
|
76 | - return $this->file->getEtag(); |
|
77 | - } else { |
|
78 | - return ''; |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Get the last modification time |
|
84 | - * |
|
85 | - * @return int |
|
86 | - */ |
|
87 | - public function getMTime() { |
|
88 | - if ($this->file) { |
|
89 | - return $this->file->getMTime(); |
|
90 | - } else { |
|
91 | - return time(); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Get the content |
|
97 | - * |
|
98 | - * @return string |
|
99 | - * @throws NotFoundException |
|
100 | - * @throws NotPermittedException |
|
101 | - */ |
|
102 | - public function getContent() { |
|
103 | - if ($this->file) { |
|
104 | - $result = $this->file->getContent(); |
|
105 | - |
|
106 | - if ($result === false) { |
|
107 | - $this->checkFile(); |
|
108 | - } |
|
109 | - |
|
110 | - return $result; |
|
111 | - } else { |
|
112 | - return ''; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Overwrite the file |
|
118 | - * |
|
119 | - * @param string|resource $data |
|
120 | - * @throws NotPermittedException |
|
121 | - * @throws NotFoundException |
|
122 | - */ |
|
123 | - public function putContent($data) { |
|
124 | - try { |
|
125 | - if ($this->file) { |
|
126 | - $this->file->putContent($data); |
|
127 | - } else { |
|
128 | - $this->file = $this->parentFolder->newFile($this->name, $data); |
|
129 | - } |
|
130 | - } catch (NotFoundException $e) { |
|
131 | - $this->checkFile(); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Sometimes there are some issues with the AppData. Most of them are from |
|
137 | - * user error. But we should handle them gracefull anyway. |
|
138 | - * |
|
139 | - * If for some reason the current file can't be found. We remove it. |
|
140 | - * Then traverse up and check all folders if they exists. This so that the |
|
141 | - * next request will have a valid appdata structure again. |
|
142 | - * |
|
143 | - * @throws NotFoundException |
|
144 | - */ |
|
145 | - private function checkFile() { |
|
146 | - $cur = $this->file; |
|
147 | - |
|
148 | - while ($cur->stat() === false) { |
|
149 | - $parent = $cur->getParent(); |
|
150 | - try { |
|
151 | - $cur->delete(); |
|
152 | - } catch (NotFoundException $e) { |
|
153 | - // Just continue then |
|
154 | - } |
|
155 | - $cur = $parent; |
|
156 | - } |
|
157 | - |
|
158 | - if ($cur !== $this->file) { |
|
159 | - throw new NotFoundException('File does not exist'); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Delete the file |
|
166 | - * |
|
167 | - * @throws NotPermittedException |
|
168 | - */ |
|
169 | - public function delete() { |
|
170 | - if ($this->file) { |
|
171 | - $this->file->delete(); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Get the MimeType |
|
177 | - * |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function getMimeType() { |
|
181 | - if ($this->file) { |
|
182 | - return $this->file->getMimeType(); |
|
183 | - } else { |
|
184 | - return 'text/plain'; |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen |
|
190 | - * |
|
191 | - * @return resource |
|
192 | - * @throws \OCP\Files\NotPermittedException |
|
193 | - * @since 14.0.0 |
|
194 | - */ |
|
195 | - public function read() { |
|
196 | - if ($this->file) { |
|
197 | - return $this->file->fopen('r'); |
|
198 | - } else { |
|
199 | - return fopen('php://temp', 'r'); |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen |
|
205 | - * |
|
206 | - * @return resource |
|
207 | - * @throws \OCP\Files\NotPermittedException |
|
208 | - * @since 14.0.0 |
|
209 | - */ |
|
210 | - public function write() { |
|
211 | - if ($this->file) { |
|
212 | - return $this->file->fopen('w'); |
|
213 | - } else { |
|
214 | - $source = fopen('php://temp', 'w+'); |
|
215 | - return CallbackWrapper::wrap($source, null, null, null, null, function () use ($source) { |
|
216 | - rewind($source); |
|
217 | - $this->putContent($source); |
|
218 | - }); |
|
219 | - } |
|
220 | - } |
|
32 | + private $parentFolder; |
|
33 | + private $name; |
|
34 | + /** @var File|null */ |
|
35 | + private $file = null; |
|
36 | + |
|
37 | + /** |
|
38 | + * File constructor. |
|
39 | + * |
|
40 | + * @param File $file |
|
41 | + */ |
|
42 | + public function __construct(Folder $parentFolder, string $name) { |
|
43 | + $this->parentFolder = $parentFolder; |
|
44 | + $this->name = $name; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Get the name |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->name; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Get the size in bytes |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function getSize() { |
|
62 | + if ($this->file) { |
|
63 | + return $this->file->getSize(); |
|
64 | + } else { |
|
65 | + return 0; |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Get the ETag |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getETag() { |
|
75 | + if ($this->file) { |
|
76 | + return $this->file->getEtag(); |
|
77 | + } else { |
|
78 | + return ''; |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Get the last modification time |
|
84 | + * |
|
85 | + * @return int |
|
86 | + */ |
|
87 | + public function getMTime() { |
|
88 | + if ($this->file) { |
|
89 | + return $this->file->getMTime(); |
|
90 | + } else { |
|
91 | + return time(); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Get the content |
|
97 | + * |
|
98 | + * @return string |
|
99 | + * @throws NotFoundException |
|
100 | + * @throws NotPermittedException |
|
101 | + */ |
|
102 | + public function getContent() { |
|
103 | + if ($this->file) { |
|
104 | + $result = $this->file->getContent(); |
|
105 | + |
|
106 | + if ($result === false) { |
|
107 | + $this->checkFile(); |
|
108 | + } |
|
109 | + |
|
110 | + return $result; |
|
111 | + } else { |
|
112 | + return ''; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Overwrite the file |
|
118 | + * |
|
119 | + * @param string|resource $data |
|
120 | + * @throws NotPermittedException |
|
121 | + * @throws NotFoundException |
|
122 | + */ |
|
123 | + public function putContent($data) { |
|
124 | + try { |
|
125 | + if ($this->file) { |
|
126 | + $this->file->putContent($data); |
|
127 | + } else { |
|
128 | + $this->file = $this->parentFolder->newFile($this->name, $data); |
|
129 | + } |
|
130 | + } catch (NotFoundException $e) { |
|
131 | + $this->checkFile(); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Sometimes there are some issues with the AppData. Most of them are from |
|
137 | + * user error. But we should handle them gracefull anyway. |
|
138 | + * |
|
139 | + * If for some reason the current file can't be found. We remove it. |
|
140 | + * Then traverse up and check all folders if they exists. This so that the |
|
141 | + * next request will have a valid appdata structure again. |
|
142 | + * |
|
143 | + * @throws NotFoundException |
|
144 | + */ |
|
145 | + private function checkFile() { |
|
146 | + $cur = $this->file; |
|
147 | + |
|
148 | + while ($cur->stat() === false) { |
|
149 | + $parent = $cur->getParent(); |
|
150 | + try { |
|
151 | + $cur->delete(); |
|
152 | + } catch (NotFoundException $e) { |
|
153 | + // Just continue then |
|
154 | + } |
|
155 | + $cur = $parent; |
|
156 | + } |
|
157 | + |
|
158 | + if ($cur !== $this->file) { |
|
159 | + throw new NotFoundException('File does not exist'); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Delete the file |
|
166 | + * |
|
167 | + * @throws NotPermittedException |
|
168 | + */ |
|
169 | + public function delete() { |
|
170 | + if ($this->file) { |
|
171 | + $this->file->delete(); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Get the MimeType |
|
177 | + * |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function getMimeType() { |
|
181 | + if ($this->file) { |
|
182 | + return $this->file->getMimeType(); |
|
183 | + } else { |
|
184 | + return 'text/plain'; |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen |
|
190 | + * |
|
191 | + * @return resource |
|
192 | + * @throws \OCP\Files\NotPermittedException |
|
193 | + * @since 14.0.0 |
|
194 | + */ |
|
195 | + public function read() { |
|
196 | + if ($this->file) { |
|
197 | + return $this->file->fopen('r'); |
|
198 | + } else { |
|
199 | + return fopen('php://temp', 'r'); |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen |
|
205 | + * |
|
206 | + * @return resource |
|
207 | + * @throws \OCP\Files\NotPermittedException |
|
208 | + * @since 14.0.0 |
|
209 | + */ |
|
210 | + public function write() { |
|
211 | + if ($this->file) { |
|
212 | + return $this->file->fopen('w'); |
|
213 | + } else { |
|
214 | + $source = fopen('php://temp', 'w+'); |
|
215 | + return CallbackWrapper::wrap($source, null, null, null, null, function () use ($source) { |
|
216 | + rewind($source); |
|
217 | + $this->putContent($source); |
|
218 | + }); |
|
219 | + } |
|
220 | + } |
|
221 | 221 | } |
@@ -212,7 +212,7 @@ |
||
212 | 212 | return $this->file->fopen('w'); |
213 | 213 | } else { |
214 | 214 | $source = fopen('php://temp', 'w+'); |
215 | - return CallbackWrapper::wrap($source, null, null, null, null, function () use ($source) { |
|
215 | + return CallbackWrapper::wrap($source, null, null, null, null, function() use ($source) { |
|
216 | 216 | rewind($source); |
217 | 217 | $this->putContent($source); |
218 | 218 | }); |
@@ -31,62 +31,62 @@ |
||
31 | 31 | |
32 | 32 | class SimpleFolder implements ISimpleFolder { |
33 | 33 | |
34 | - /** @var Folder */ |
|
35 | - private $folder; |
|
36 | - |
|
37 | - /** |
|
38 | - * Folder constructor. |
|
39 | - * |
|
40 | - * @param Folder $folder |
|
41 | - */ |
|
42 | - public function __construct(Folder $folder) { |
|
43 | - $this->folder = $folder; |
|
44 | - } |
|
45 | - |
|
46 | - public function getName() { |
|
47 | - return $this->folder->getName(); |
|
48 | - } |
|
49 | - |
|
50 | - public function getDirectoryListing() { |
|
51 | - $listing = $this->folder->getDirectoryListing(); |
|
52 | - |
|
53 | - $fileListing = array_map(function(Node $file) { |
|
54 | - if ($file instanceof File) { |
|
55 | - return new SimpleFile($file); |
|
56 | - } |
|
57 | - return null; |
|
58 | - }, $listing); |
|
59 | - |
|
60 | - $fileListing = array_filter($fileListing); |
|
61 | - |
|
62 | - return array_values($fileListing); |
|
63 | - } |
|
64 | - |
|
65 | - public function delete() { |
|
66 | - $this->folder->delete(); |
|
67 | - } |
|
68 | - |
|
69 | - public function fileExists($name) { |
|
70 | - return $this->folder->nodeExists($name); |
|
71 | - } |
|
72 | - |
|
73 | - public function getFile($name) { |
|
74 | - $file = $this->folder->get($name); |
|
75 | - |
|
76 | - if (!($file instanceof File)) { |
|
77 | - throw new NotFoundException(); |
|
78 | - } |
|
79 | - |
|
80 | - return new SimpleFile($file); |
|
81 | - } |
|
82 | - |
|
83 | - public function newFile($name, $content = null) { |
|
84 | - if ($content === null) { |
|
85 | - // delay creating the file until it's written to |
|
86 | - return new NewSimpleFile($this->folder, $name); |
|
87 | - } else { |
|
88 | - $file = $this->folder->newFile($name, $content); |
|
89 | - return new SimpleFile($file); |
|
90 | - } |
|
91 | - } |
|
34 | + /** @var Folder */ |
|
35 | + private $folder; |
|
36 | + |
|
37 | + /** |
|
38 | + * Folder constructor. |
|
39 | + * |
|
40 | + * @param Folder $folder |
|
41 | + */ |
|
42 | + public function __construct(Folder $folder) { |
|
43 | + $this->folder = $folder; |
|
44 | + } |
|
45 | + |
|
46 | + public function getName() { |
|
47 | + return $this->folder->getName(); |
|
48 | + } |
|
49 | + |
|
50 | + public function getDirectoryListing() { |
|
51 | + $listing = $this->folder->getDirectoryListing(); |
|
52 | + |
|
53 | + $fileListing = array_map(function(Node $file) { |
|
54 | + if ($file instanceof File) { |
|
55 | + return new SimpleFile($file); |
|
56 | + } |
|
57 | + return null; |
|
58 | + }, $listing); |
|
59 | + |
|
60 | + $fileListing = array_filter($fileListing); |
|
61 | + |
|
62 | + return array_values($fileListing); |
|
63 | + } |
|
64 | + |
|
65 | + public function delete() { |
|
66 | + $this->folder->delete(); |
|
67 | + } |
|
68 | + |
|
69 | + public function fileExists($name) { |
|
70 | + return $this->folder->nodeExists($name); |
|
71 | + } |
|
72 | + |
|
73 | + public function getFile($name) { |
|
74 | + $file = $this->folder->get($name); |
|
75 | + |
|
76 | + if (!($file instanceof File)) { |
|
77 | + throw new NotFoundException(); |
|
78 | + } |
|
79 | + |
|
80 | + return new SimpleFile($file); |
|
81 | + } |
|
82 | + |
|
83 | + public function newFile($name, $content = null) { |
|
84 | + if ($content === null) { |
|
85 | + // delay creating the file until it's written to |
|
86 | + return new NewSimpleFile($this->folder, $name); |
|
87 | + } else { |
|
88 | + $file = $this->folder->newFile($name, $content); |
|
89 | + return new SimpleFile($file); |
|
90 | + } |
|
91 | + } |
|
92 | 92 | } |
@@ -27,147 +27,147 @@ |
||
27 | 27 | use OCP\Files\NotFoundException; |
28 | 28 | |
29 | 29 | class NonExistingFolder extends Folder { |
30 | - /** |
|
31 | - * @param string $newPath |
|
32 | - * @throws \OCP\Files\NotFoundException |
|
33 | - */ |
|
34 | - public function rename($newPath) { |
|
35 | - throw new NotFoundException(); |
|
36 | - } |
|
37 | - |
|
38 | - public function delete() { |
|
39 | - throw new NotFoundException(); |
|
40 | - } |
|
41 | - |
|
42 | - public function copy($newPath) { |
|
43 | - throw new NotFoundException(); |
|
44 | - } |
|
45 | - |
|
46 | - public function touch($mtime = null) { |
|
47 | - throw new NotFoundException(); |
|
48 | - } |
|
49 | - |
|
50 | - public function getId() { |
|
51 | - if ($this->fileInfo) { |
|
52 | - return parent::getId(); |
|
53 | - } else { |
|
54 | - throw new NotFoundException(); |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - public function stat() { |
|
59 | - throw new NotFoundException(); |
|
60 | - } |
|
61 | - |
|
62 | - public function getMTime() { |
|
63 | - if ($this->fileInfo) { |
|
64 | - return parent::getMTime(); |
|
65 | - } else { |
|
66 | - throw new NotFoundException(); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - public function getSize($includeMounts = true) { |
|
71 | - if ($this->fileInfo) { |
|
72 | - return parent::getSize($includeMounts); |
|
73 | - } else { |
|
74 | - throw new NotFoundException(); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - public function getEtag() { |
|
79 | - if ($this->fileInfo) { |
|
80 | - return parent::getEtag(); |
|
81 | - } else { |
|
82 | - throw new NotFoundException(); |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - public function getPermissions() { |
|
87 | - if ($this->fileInfo) { |
|
88 | - return parent::getPermissions(); |
|
89 | - } else { |
|
90 | - throw new NotFoundException(); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - public function isReadable() { |
|
95 | - if ($this->fileInfo) { |
|
96 | - return parent::isReadable(); |
|
97 | - } else { |
|
98 | - throw new NotFoundException(); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - public function isUpdateable() { |
|
103 | - if ($this->fileInfo) { |
|
104 | - return parent::isUpdateable(); |
|
105 | - } else { |
|
106 | - throw new NotFoundException(); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - public function isDeletable() { |
|
111 | - if ($this->fileInfo) { |
|
112 | - return parent::isDeletable(); |
|
113 | - } else { |
|
114 | - throw new NotFoundException(); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - public function isShareable() { |
|
119 | - if ($this->fileInfo) { |
|
120 | - return parent::isShareable(); |
|
121 | - } else { |
|
122 | - throw new NotFoundException(); |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - public function get($path) { |
|
127 | - throw new NotFoundException(); |
|
128 | - } |
|
129 | - |
|
130 | - public function getDirectoryListing() { |
|
131 | - throw new NotFoundException(); |
|
132 | - } |
|
133 | - |
|
134 | - public function nodeExists($path) { |
|
135 | - return false; |
|
136 | - } |
|
137 | - |
|
138 | - public function newFolder($path) { |
|
139 | - throw new NotFoundException(); |
|
140 | - } |
|
141 | - |
|
142 | - public function newFile($path, $content = null) { |
|
143 | - throw new NotFoundException(); |
|
144 | - } |
|
145 | - |
|
146 | - public function search($pattern) { |
|
147 | - throw new NotFoundException(); |
|
148 | - } |
|
149 | - |
|
150 | - public function searchByMime($mime) { |
|
151 | - throw new NotFoundException(); |
|
152 | - } |
|
153 | - |
|
154 | - public function searchByTag($tag, $userId) { |
|
155 | - throw new NotFoundException(); |
|
156 | - } |
|
157 | - |
|
158 | - public function getById($id) { |
|
159 | - throw new NotFoundException(); |
|
160 | - } |
|
161 | - |
|
162 | - public function getFreeSpace() { |
|
163 | - throw new NotFoundException(); |
|
164 | - } |
|
165 | - |
|
166 | - public function isCreatable() { |
|
167 | - if ($this->fileInfo) { |
|
168 | - return parent::isCreatable(); |
|
169 | - } else { |
|
170 | - throw new NotFoundException(); |
|
171 | - } |
|
172 | - } |
|
30 | + /** |
|
31 | + * @param string $newPath |
|
32 | + * @throws \OCP\Files\NotFoundException |
|
33 | + */ |
|
34 | + public function rename($newPath) { |
|
35 | + throw new NotFoundException(); |
|
36 | + } |
|
37 | + |
|
38 | + public function delete() { |
|
39 | + throw new NotFoundException(); |
|
40 | + } |
|
41 | + |
|
42 | + public function copy($newPath) { |
|
43 | + throw new NotFoundException(); |
|
44 | + } |
|
45 | + |
|
46 | + public function touch($mtime = null) { |
|
47 | + throw new NotFoundException(); |
|
48 | + } |
|
49 | + |
|
50 | + public function getId() { |
|
51 | + if ($this->fileInfo) { |
|
52 | + return parent::getId(); |
|
53 | + } else { |
|
54 | + throw new NotFoundException(); |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + public function stat() { |
|
59 | + throw new NotFoundException(); |
|
60 | + } |
|
61 | + |
|
62 | + public function getMTime() { |
|
63 | + if ($this->fileInfo) { |
|
64 | + return parent::getMTime(); |
|
65 | + } else { |
|
66 | + throw new NotFoundException(); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + public function getSize($includeMounts = true) { |
|
71 | + if ($this->fileInfo) { |
|
72 | + return parent::getSize($includeMounts); |
|
73 | + } else { |
|
74 | + throw new NotFoundException(); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + public function getEtag() { |
|
79 | + if ($this->fileInfo) { |
|
80 | + return parent::getEtag(); |
|
81 | + } else { |
|
82 | + throw new NotFoundException(); |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + public function getPermissions() { |
|
87 | + if ($this->fileInfo) { |
|
88 | + return parent::getPermissions(); |
|
89 | + } else { |
|
90 | + throw new NotFoundException(); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + public function isReadable() { |
|
95 | + if ($this->fileInfo) { |
|
96 | + return parent::isReadable(); |
|
97 | + } else { |
|
98 | + throw new NotFoundException(); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + public function isUpdateable() { |
|
103 | + if ($this->fileInfo) { |
|
104 | + return parent::isUpdateable(); |
|
105 | + } else { |
|
106 | + throw new NotFoundException(); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + public function isDeletable() { |
|
111 | + if ($this->fileInfo) { |
|
112 | + return parent::isDeletable(); |
|
113 | + } else { |
|
114 | + throw new NotFoundException(); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + public function isShareable() { |
|
119 | + if ($this->fileInfo) { |
|
120 | + return parent::isShareable(); |
|
121 | + } else { |
|
122 | + throw new NotFoundException(); |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + public function get($path) { |
|
127 | + throw new NotFoundException(); |
|
128 | + } |
|
129 | + |
|
130 | + public function getDirectoryListing() { |
|
131 | + throw new NotFoundException(); |
|
132 | + } |
|
133 | + |
|
134 | + public function nodeExists($path) { |
|
135 | + return false; |
|
136 | + } |
|
137 | + |
|
138 | + public function newFolder($path) { |
|
139 | + throw new NotFoundException(); |
|
140 | + } |
|
141 | + |
|
142 | + public function newFile($path, $content = null) { |
|
143 | + throw new NotFoundException(); |
|
144 | + } |
|
145 | + |
|
146 | + public function search($pattern) { |
|
147 | + throw new NotFoundException(); |
|
148 | + } |
|
149 | + |
|
150 | + public function searchByMime($mime) { |
|
151 | + throw new NotFoundException(); |
|
152 | + } |
|
153 | + |
|
154 | + public function searchByTag($tag, $userId) { |
|
155 | + throw new NotFoundException(); |
|
156 | + } |
|
157 | + |
|
158 | + public function getById($id) { |
|
159 | + throw new NotFoundException(); |
|
160 | + } |
|
161 | + |
|
162 | + public function getFreeSpace() { |
|
163 | + throw new NotFoundException(); |
|
164 | + } |
|
165 | + |
|
166 | + public function isCreatable() { |
|
167 | + if ($this->fileInfo) { |
|
168 | + return parent::isCreatable(); |
|
169 | + } else { |
|
170 | + throw new NotFoundException(); |
|
171 | + } |
|
172 | + } |
|
173 | 173 | } |
@@ -34,465 +34,465 @@ |
||
34 | 34 | * @package OC\Files\Node |
35 | 35 | */ |
36 | 36 | class LazyRoot implements IRootFolder { |
37 | - /** @var \Closure */ |
|
38 | - private $rootFolderClosure; |
|
39 | - |
|
40 | - /** @var IRootFolder */ |
|
41 | - private $rootFolder; |
|
42 | - |
|
43 | - /** |
|
44 | - * LazyRoot constructor. |
|
45 | - * |
|
46 | - * @param \Closure $rootFolderClosure |
|
47 | - */ |
|
48 | - public function __construct(\Closure $rootFolderClosure) { |
|
49 | - $this->rootFolderClosure = $rootFolderClosure; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Magic method to first get the real rootFolder and then |
|
54 | - * call $method with $args on it |
|
55 | - * |
|
56 | - * @param $method |
|
57 | - * @param $args |
|
58 | - * @return mixed |
|
59 | - */ |
|
60 | - public function __call($method, $args) { |
|
61 | - if ($this->rootFolder === null) { |
|
62 | - $this->rootFolder = call_user_func($this->rootFolderClosure); |
|
63 | - } |
|
64 | - |
|
65 | - return call_user_func_array([$this->rootFolder, $method], $args); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @inheritDoc |
|
70 | - */ |
|
71 | - public function getUser() { |
|
72 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @inheritDoc |
|
77 | - */ |
|
78 | - public function listen($scope, $method, callable $callback) { |
|
79 | - $this->__call(__FUNCTION__, func_get_args()); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @inheritDoc |
|
84 | - */ |
|
85 | - public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
86 | - $this->__call(__FUNCTION__, func_get_args()); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @inheritDoc |
|
91 | - */ |
|
92 | - public function emit($scope, $method, $arguments = array()) { |
|
93 | - $this->__call(__FUNCTION__, func_get_args()); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @inheritDoc |
|
98 | - */ |
|
99 | - public function mount($storage, $mountPoint, $arguments = array()) { |
|
100 | - $this->__call(__FUNCTION__, func_get_args()); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @inheritDoc |
|
105 | - */ |
|
106 | - public function getMount($mountPoint) { |
|
107 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * @inheritDoc |
|
112 | - */ |
|
113 | - public function getMountsIn($mountPoint) { |
|
114 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @inheritDoc |
|
119 | - */ |
|
120 | - public function getMountByStorageId($storageId) { |
|
121 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @inheritDoc |
|
126 | - */ |
|
127 | - public function getMountByNumericStorageId($numericId) { |
|
128 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @inheritDoc |
|
133 | - */ |
|
134 | - public function unMount($mount) { |
|
135 | - $this->__call(__FUNCTION__, func_get_args()); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @inheritDoc |
|
140 | - */ |
|
141 | - public function get($path) { |
|
142 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * @inheritDoc |
|
147 | - */ |
|
148 | - public function rename($targetPath) { |
|
149 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @inheritDoc |
|
154 | - */ |
|
155 | - public function delete() { |
|
156 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @inheritDoc |
|
161 | - */ |
|
162 | - public function copy($targetPath) { |
|
163 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @inheritDoc |
|
168 | - */ |
|
169 | - public function touch($mtime = null) { |
|
170 | - $this->__call(__FUNCTION__, func_get_args()); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * @inheritDoc |
|
175 | - */ |
|
176 | - public function getStorage() { |
|
177 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @inheritDoc |
|
182 | - */ |
|
183 | - public function getPath() { |
|
184 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * @inheritDoc |
|
189 | - */ |
|
190 | - public function getInternalPath() { |
|
191 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @inheritDoc |
|
196 | - */ |
|
197 | - public function getId() { |
|
198 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * @inheritDoc |
|
203 | - */ |
|
204 | - public function stat() { |
|
205 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * @inheritDoc |
|
210 | - */ |
|
211 | - public function getMTime() { |
|
212 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * @inheritDoc |
|
217 | - */ |
|
218 | - public function getSize($includeMounts = true) { |
|
219 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * @inheritDoc |
|
224 | - */ |
|
225 | - public function getEtag() { |
|
226 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * @inheritDoc |
|
231 | - */ |
|
232 | - public function getPermissions() { |
|
233 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * @inheritDoc |
|
238 | - */ |
|
239 | - public function isReadable() { |
|
240 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * @inheritDoc |
|
245 | - */ |
|
246 | - public function isUpdateable() { |
|
247 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * @inheritDoc |
|
252 | - */ |
|
253 | - public function isDeletable() { |
|
254 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * @inheritDoc |
|
259 | - */ |
|
260 | - public function isShareable() { |
|
261 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * @inheritDoc |
|
266 | - */ |
|
267 | - public function getParent() { |
|
268 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * @inheritDoc |
|
273 | - */ |
|
274 | - public function getName() { |
|
275 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * @inheritDoc |
|
280 | - */ |
|
281 | - public function getUserFolder($userId) { |
|
282 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * @inheritDoc |
|
287 | - */ |
|
288 | - public function getMimetype() { |
|
289 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * @inheritDoc |
|
294 | - */ |
|
295 | - public function getMimePart() { |
|
296 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * @inheritDoc |
|
301 | - */ |
|
302 | - public function isEncrypted() { |
|
303 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * @inheritDoc |
|
308 | - */ |
|
309 | - public function getType() { |
|
310 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * @inheritDoc |
|
315 | - */ |
|
316 | - public function isShared() { |
|
317 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
318 | - } |
|
319 | - |
|
320 | - /** |
|
321 | - * @inheritDoc |
|
322 | - */ |
|
323 | - public function isMounted() { |
|
324 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
325 | - } |
|
326 | - |
|
327 | - /** |
|
328 | - * @inheritDoc |
|
329 | - */ |
|
330 | - public function getMountPoint() { |
|
331 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * @inheritDoc |
|
336 | - */ |
|
337 | - public function getOwner() { |
|
338 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * @inheritDoc |
|
343 | - */ |
|
344 | - public function getChecksum() { |
|
345 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
346 | - } |
|
347 | - |
|
348 | - public function getExtension(): string { |
|
349 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * @inheritDoc |
|
354 | - */ |
|
355 | - public function getFullPath($path) { |
|
356 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * @inheritDoc |
|
361 | - */ |
|
362 | - public function getRelativePath($path) { |
|
363 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * @inheritDoc |
|
368 | - */ |
|
369 | - public function isSubNode($node) { |
|
370 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * @inheritDoc |
|
375 | - */ |
|
376 | - public function getDirectoryListing() { |
|
377 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * @inheritDoc |
|
382 | - */ |
|
383 | - public function nodeExists($path) { |
|
384 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * @inheritDoc |
|
389 | - */ |
|
390 | - public function newFolder($path) { |
|
391 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
392 | - } |
|
393 | - |
|
394 | - /** |
|
395 | - * @inheritDoc |
|
396 | - */ |
|
397 | - public function newFile($path, $content = null) { |
|
398 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * @inheritDoc |
|
403 | - */ |
|
404 | - public function search($query) { |
|
405 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * @inheritDoc |
|
410 | - */ |
|
411 | - public function searchByMime($mimetype) { |
|
412 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * @inheritDoc |
|
417 | - */ |
|
418 | - public function searchByTag($tag, $userId) { |
|
419 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * @inheritDoc |
|
424 | - */ |
|
425 | - public function getById($id) { |
|
426 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * @inheritDoc |
|
431 | - */ |
|
432 | - public function getFreeSpace() { |
|
433 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * @inheritDoc |
|
438 | - */ |
|
439 | - public function isCreatable() { |
|
440 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
444 | - * @inheritDoc |
|
445 | - */ |
|
446 | - public function getNonExistingName($name) { |
|
447 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * @inheritDoc |
|
452 | - */ |
|
453 | - public function move($targetPath) { |
|
454 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
455 | - } |
|
456 | - |
|
457 | - /** |
|
458 | - * @inheritDoc |
|
459 | - */ |
|
460 | - public function lock($type) { |
|
461 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * @inheritDoc |
|
466 | - */ |
|
467 | - public function changeLock($targetType) { |
|
468 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
469 | - } |
|
470 | - |
|
471 | - /** |
|
472 | - * @inheritDoc |
|
473 | - */ |
|
474 | - public function unlock($type) { |
|
475 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * @inheritDoc |
|
480 | - */ |
|
481 | - public function getRecent($limit, $offset = 0) { |
|
482 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
483 | - } |
|
484 | - |
|
485 | - /** |
|
486 | - * @inheritDoc |
|
487 | - */ |
|
488 | - public function getCreationTime(): int { |
|
489 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
490 | - } |
|
491 | - |
|
492 | - /** |
|
493 | - * @inheritDoc |
|
494 | - */ |
|
495 | - public function getUploadTime(): int { |
|
496 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
497 | - } |
|
37 | + /** @var \Closure */ |
|
38 | + private $rootFolderClosure; |
|
39 | + |
|
40 | + /** @var IRootFolder */ |
|
41 | + private $rootFolder; |
|
42 | + |
|
43 | + /** |
|
44 | + * LazyRoot constructor. |
|
45 | + * |
|
46 | + * @param \Closure $rootFolderClosure |
|
47 | + */ |
|
48 | + public function __construct(\Closure $rootFolderClosure) { |
|
49 | + $this->rootFolderClosure = $rootFolderClosure; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Magic method to first get the real rootFolder and then |
|
54 | + * call $method with $args on it |
|
55 | + * |
|
56 | + * @param $method |
|
57 | + * @param $args |
|
58 | + * @return mixed |
|
59 | + */ |
|
60 | + public function __call($method, $args) { |
|
61 | + if ($this->rootFolder === null) { |
|
62 | + $this->rootFolder = call_user_func($this->rootFolderClosure); |
|
63 | + } |
|
64 | + |
|
65 | + return call_user_func_array([$this->rootFolder, $method], $args); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @inheritDoc |
|
70 | + */ |
|
71 | + public function getUser() { |
|
72 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @inheritDoc |
|
77 | + */ |
|
78 | + public function listen($scope, $method, callable $callback) { |
|
79 | + $this->__call(__FUNCTION__, func_get_args()); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @inheritDoc |
|
84 | + */ |
|
85 | + public function removeListener($scope = null, $method = null, callable $callback = null) { |
|
86 | + $this->__call(__FUNCTION__, func_get_args()); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @inheritDoc |
|
91 | + */ |
|
92 | + public function emit($scope, $method, $arguments = array()) { |
|
93 | + $this->__call(__FUNCTION__, func_get_args()); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @inheritDoc |
|
98 | + */ |
|
99 | + public function mount($storage, $mountPoint, $arguments = array()) { |
|
100 | + $this->__call(__FUNCTION__, func_get_args()); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @inheritDoc |
|
105 | + */ |
|
106 | + public function getMount($mountPoint) { |
|
107 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * @inheritDoc |
|
112 | + */ |
|
113 | + public function getMountsIn($mountPoint) { |
|
114 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @inheritDoc |
|
119 | + */ |
|
120 | + public function getMountByStorageId($storageId) { |
|
121 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @inheritDoc |
|
126 | + */ |
|
127 | + public function getMountByNumericStorageId($numericId) { |
|
128 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @inheritDoc |
|
133 | + */ |
|
134 | + public function unMount($mount) { |
|
135 | + $this->__call(__FUNCTION__, func_get_args()); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @inheritDoc |
|
140 | + */ |
|
141 | + public function get($path) { |
|
142 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * @inheritDoc |
|
147 | + */ |
|
148 | + public function rename($targetPath) { |
|
149 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @inheritDoc |
|
154 | + */ |
|
155 | + public function delete() { |
|
156 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @inheritDoc |
|
161 | + */ |
|
162 | + public function copy($targetPath) { |
|
163 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @inheritDoc |
|
168 | + */ |
|
169 | + public function touch($mtime = null) { |
|
170 | + $this->__call(__FUNCTION__, func_get_args()); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * @inheritDoc |
|
175 | + */ |
|
176 | + public function getStorage() { |
|
177 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @inheritDoc |
|
182 | + */ |
|
183 | + public function getPath() { |
|
184 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * @inheritDoc |
|
189 | + */ |
|
190 | + public function getInternalPath() { |
|
191 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @inheritDoc |
|
196 | + */ |
|
197 | + public function getId() { |
|
198 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * @inheritDoc |
|
203 | + */ |
|
204 | + public function stat() { |
|
205 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * @inheritDoc |
|
210 | + */ |
|
211 | + public function getMTime() { |
|
212 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * @inheritDoc |
|
217 | + */ |
|
218 | + public function getSize($includeMounts = true) { |
|
219 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * @inheritDoc |
|
224 | + */ |
|
225 | + public function getEtag() { |
|
226 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * @inheritDoc |
|
231 | + */ |
|
232 | + public function getPermissions() { |
|
233 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * @inheritDoc |
|
238 | + */ |
|
239 | + public function isReadable() { |
|
240 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * @inheritDoc |
|
245 | + */ |
|
246 | + public function isUpdateable() { |
|
247 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * @inheritDoc |
|
252 | + */ |
|
253 | + public function isDeletable() { |
|
254 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * @inheritDoc |
|
259 | + */ |
|
260 | + public function isShareable() { |
|
261 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * @inheritDoc |
|
266 | + */ |
|
267 | + public function getParent() { |
|
268 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * @inheritDoc |
|
273 | + */ |
|
274 | + public function getName() { |
|
275 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * @inheritDoc |
|
280 | + */ |
|
281 | + public function getUserFolder($userId) { |
|
282 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * @inheritDoc |
|
287 | + */ |
|
288 | + public function getMimetype() { |
|
289 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * @inheritDoc |
|
294 | + */ |
|
295 | + public function getMimePart() { |
|
296 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * @inheritDoc |
|
301 | + */ |
|
302 | + public function isEncrypted() { |
|
303 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * @inheritDoc |
|
308 | + */ |
|
309 | + public function getType() { |
|
310 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * @inheritDoc |
|
315 | + */ |
|
316 | + public function isShared() { |
|
317 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
318 | + } |
|
319 | + |
|
320 | + /** |
|
321 | + * @inheritDoc |
|
322 | + */ |
|
323 | + public function isMounted() { |
|
324 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
325 | + } |
|
326 | + |
|
327 | + /** |
|
328 | + * @inheritDoc |
|
329 | + */ |
|
330 | + public function getMountPoint() { |
|
331 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * @inheritDoc |
|
336 | + */ |
|
337 | + public function getOwner() { |
|
338 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * @inheritDoc |
|
343 | + */ |
|
344 | + public function getChecksum() { |
|
345 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
346 | + } |
|
347 | + |
|
348 | + public function getExtension(): string { |
|
349 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * @inheritDoc |
|
354 | + */ |
|
355 | + public function getFullPath($path) { |
|
356 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * @inheritDoc |
|
361 | + */ |
|
362 | + public function getRelativePath($path) { |
|
363 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * @inheritDoc |
|
368 | + */ |
|
369 | + public function isSubNode($node) { |
|
370 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * @inheritDoc |
|
375 | + */ |
|
376 | + public function getDirectoryListing() { |
|
377 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * @inheritDoc |
|
382 | + */ |
|
383 | + public function nodeExists($path) { |
|
384 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * @inheritDoc |
|
389 | + */ |
|
390 | + public function newFolder($path) { |
|
391 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
392 | + } |
|
393 | + |
|
394 | + /** |
|
395 | + * @inheritDoc |
|
396 | + */ |
|
397 | + public function newFile($path, $content = null) { |
|
398 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * @inheritDoc |
|
403 | + */ |
|
404 | + public function search($query) { |
|
405 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
406 | + } |
|
407 | + |
|
408 | + /** |
|
409 | + * @inheritDoc |
|
410 | + */ |
|
411 | + public function searchByMime($mimetype) { |
|
412 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * @inheritDoc |
|
417 | + */ |
|
418 | + public function searchByTag($tag, $userId) { |
|
419 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * @inheritDoc |
|
424 | + */ |
|
425 | + public function getById($id) { |
|
426 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
427 | + } |
|
428 | + |
|
429 | + /** |
|
430 | + * @inheritDoc |
|
431 | + */ |
|
432 | + public function getFreeSpace() { |
|
433 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * @inheritDoc |
|
438 | + */ |
|
439 | + public function isCreatable() { |
|
440 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * @inheritDoc |
|
445 | + */ |
|
446 | + public function getNonExistingName($name) { |
|
447 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * @inheritDoc |
|
452 | + */ |
|
453 | + public function move($targetPath) { |
|
454 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
455 | + } |
|
456 | + |
|
457 | + /** |
|
458 | + * @inheritDoc |
|
459 | + */ |
|
460 | + public function lock($type) { |
|
461 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * @inheritDoc |
|
466 | + */ |
|
467 | + public function changeLock($targetType) { |
|
468 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
469 | + } |
|
470 | + |
|
471 | + /** |
|
472 | + * @inheritDoc |
|
473 | + */ |
|
474 | + public function unlock($type) { |
|
475 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * @inheritDoc |
|
480 | + */ |
|
481 | + public function getRecent($limit, $offset = 0) { |
|
482 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
483 | + } |
|
484 | + |
|
485 | + /** |
|
486 | + * @inheritDoc |
|
487 | + */ |
|
488 | + public function getCreationTime(): int { |
|
489 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
490 | + } |
|
491 | + |
|
492 | + /** |
|
493 | + * @inheritDoc |
|
494 | + */ |
|
495 | + public function getUploadTime(): int { |
|
496 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
497 | + } |
|
498 | 498 | } |
@@ -40,493 +40,493 @@ |
||
40 | 40 | use OCP\Files\Search\ISearchQuery; |
41 | 41 | |
42 | 42 | class Folder extends Node implements \OCP\Files\Folder { |
43 | - /** |
|
44 | - * Creates a Folder that represents a non-existing path |
|
45 | - * |
|
46 | - * @param string $path path |
|
47 | - * @return string non-existing node class |
|
48 | - */ |
|
49 | - protected function createNonExistingNode($path) { |
|
50 | - return new NonExistingFolder($this->root, $this->view, $path); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $path path relative to the folder |
|
55 | - * @return string |
|
56 | - * @throws \OCP\Files\NotPermittedException |
|
57 | - */ |
|
58 | - public function getFullPath($path) { |
|
59 | - if (!$this->isValidPath($path)) { |
|
60 | - throw new NotPermittedException('Invalid path'); |
|
61 | - } |
|
62 | - return $this->path . $this->normalizePath($path); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @param string $path |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function getRelativePath($path) { |
|
70 | - if ($this->path === '' or $this->path === '/') { |
|
71 | - return $this->normalizePath($path); |
|
72 | - } |
|
73 | - if ($path === $this->path) { |
|
74 | - return '/'; |
|
75 | - } else if (strpos($path, $this->path . '/') !== 0) { |
|
76 | - return null; |
|
77 | - } else { |
|
78 | - $path = substr($path, strlen($this->path)); |
|
79 | - return $this->normalizePath($path); |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * check if a node is a (grand-)child of the folder |
|
85 | - * |
|
86 | - * @param \OC\Files\Node\Node $node |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function isSubNode($node) { |
|
90 | - return strpos($node->getPath(), $this->path . '/') === 0; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * get the content of this directory |
|
95 | - * |
|
96 | - * @throws \OCP\Files\NotFoundException |
|
97 | - * @return Node[] |
|
98 | - */ |
|
99 | - public function getDirectoryListing() { |
|
100 | - $folderContent = $this->view->getDirectoryContent($this->path); |
|
101 | - |
|
102 | - return array_map(function (FileInfo $info) { |
|
103 | - if ($info->getMimetype() === 'httpd/unix-directory') { |
|
104 | - return new Folder($this->root, $this->view, $info->getPath(), $info); |
|
105 | - } else { |
|
106 | - return new File($this->root, $this->view, $info->getPath(), $info); |
|
107 | - } |
|
108 | - }, $folderContent); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $path |
|
113 | - * @param FileInfo $info |
|
114 | - * @return File|Folder |
|
115 | - */ |
|
116 | - protected function createNode($path, FileInfo $info = null) { |
|
117 | - if (is_null($info)) { |
|
118 | - $isDir = $this->view->is_dir($path); |
|
119 | - } else { |
|
120 | - $isDir = $info->getType() === FileInfo::TYPE_FOLDER; |
|
121 | - } |
|
122 | - if ($isDir) { |
|
123 | - return new Folder($this->root, $this->view, $path, $info); |
|
124 | - } else { |
|
125 | - return new File($this->root, $this->view, $path, $info); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Get the node at $path |
|
131 | - * |
|
132 | - * @param string $path |
|
133 | - * @return \OC\Files\Node\Node |
|
134 | - * @throws \OCP\Files\NotFoundException |
|
135 | - */ |
|
136 | - public function get($path) { |
|
137 | - return $this->root->get($this->getFullPath($path)); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $path |
|
142 | - * @return bool |
|
143 | - */ |
|
144 | - public function nodeExists($path) { |
|
145 | - try { |
|
146 | - $this->get($path); |
|
147 | - return true; |
|
148 | - } catch (NotFoundException $e) { |
|
149 | - return false; |
|
150 | - } |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @param string $path |
|
155 | - * @return \OC\Files\Node\Folder |
|
156 | - * @throws \OCP\Files\NotPermittedException |
|
157 | - */ |
|
158 | - public function newFolder($path) { |
|
159 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { |
|
160 | - $fullPath = $this->getFullPath($path); |
|
161 | - $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); |
|
162 | - $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); |
|
163 | - if(!$this->view->mkdir($fullPath)) { |
|
164 | - throw new NotPermittedException('Could not create folder'); |
|
165 | - } |
|
166 | - $node = new Folder($this->root, $this->view, $fullPath); |
|
167 | - $this->sendHooks(['postWrite', 'postCreate'], [$node]); |
|
168 | - return $node; |
|
169 | - } else { |
|
170 | - throw new NotPermittedException('No create permission for folder'); |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @param string $path |
|
176 | - * @param string | resource | null $content |
|
177 | - * @return \OC\Files\Node\File |
|
178 | - * @throws \OCP\Files\NotPermittedException |
|
179 | - */ |
|
180 | - public function newFile($path, $content = null) { |
|
181 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { |
|
182 | - $fullPath = $this->getFullPath($path); |
|
183 | - $nonExisting = new NonExistingFile($this->root, $this->view, $fullPath); |
|
184 | - $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); |
|
185 | - if ($content !== null) { |
|
186 | - $result = $this->view->file_put_contents($fullPath, $content); |
|
187 | - } else { |
|
188 | - $result = $this->view->touch($fullPath); |
|
189 | - } |
|
190 | - if (!$result) { |
|
191 | - throw new NotPermittedException('Could not create path'); |
|
192 | - } |
|
193 | - $node = new File($this->root, $this->view, $fullPath); |
|
194 | - $this->sendHooks(['postWrite', 'postCreate'], [$node]); |
|
195 | - return $node; |
|
196 | - } |
|
197 | - throw new NotPermittedException('No create permission for path'); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * search for files with the name matching $query |
|
202 | - * |
|
203 | - * @param string|ISearchQuery $query |
|
204 | - * @return \OC\Files\Node\Node[] |
|
205 | - */ |
|
206 | - public function search($query) { |
|
207 | - if (is_string($query)) { |
|
208 | - return $this->searchCommon('search', array('%' . $query . '%')); |
|
209 | - } else { |
|
210 | - return $this->searchCommon('searchQuery', array($query)); |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * search for files by mimetype |
|
216 | - * |
|
217 | - * @param string $mimetype |
|
218 | - * @return Node[] |
|
219 | - */ |
|
220 | - public function searchByMime($mimetype) { |
|
221 | - return $this->searchCommon('searchByMime', array($mimetype)); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * search for files by tag |
|
226 | - * |
|
227 | - * @param string|int $tag name or tag id |
|
228 | - * @param string $userId owner of the tags |
|
229 | - * @return Node[] |
|
230 | - */ |
|
231 | - public function searchByTag($tag, $userId) { |
|
232 | - return $this->searchCommon('searchByTag', array($tag, $userId)); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * @param string $method cache method |
|
237 | - * @param array $args call args |
|
238 | - * @return \OC\Files\Node\Node[] |
|
239 | - */ |
|
240 | - private function searchCommon($method, $args) { |
|
241 | - $limitToHome = ($method === 'searchQuery')? $args[0]->limitToHome(): false; |
|
242 | - if ($limitToHome && count(explode('/', $this->path)) !== 3) { |
|
243 | - throw new \InvalidArgumentException('searching by owner is only allows on the users home folder'); |
|
244 | - } |
|
245 | - |
|
246 | - $files = array(); |
|
247 | - $rootLength = strlen($this->path); |
|
248 | - $mount = $this->root->getMount($this->path); |
|
249 | - $storage = $mount->getStorage(); |
|
250 | - $internalPath = $mount->getInternalPath($this->path); |
|
251 | - $internalPath = rtrim($internalPath, '/'); |
|
252 | - if ($internalPath !== '') { |
|
253 | - $internalPath = $internalPath . '/'; |
|
254 | - } |
|
255 | - $internalRootLength = strlen($internalPath); |
|
256 | - |
|
257 | - $cache = $storage->getCache(''); |
|
258 | - |
|
259 | - $results = call_user_func_array(array($cache, $method), $args); |
|
260 | - foreach ($results as $result) { |
|
261 | - if ($internalRootLength === 0 or substr($result['path'], 0, $internalRootLength) === $internalPath) { |
|
262 | - $result['internalPath'] = $result['path']; |
|
263 | - $result['path'] = substr($result['path'], $internalRootLength); |
|
264 | - $result['storage'] = $storage; |
|
265 | - $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, $result['internalPath'], $result, $mount); |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - if (!$limitToHome) { |
|
270 | - $mounts = $this->root->getMountsIn($this->path); |
|
271 | - foreach ($mounts as $mount) { |
|
272 | - $storage = $mount->getStorage(); |
|
273 | - if ($storage) { |
|
274 | - $cache = $storage->getCache(''); |
|
275 | - |
|
276 | - $relativeMountPoint = ltrim(substr($mount->getMountPoint(), $rootLength), '/'); |
|
277 | - $results = call_user_func_array([$cache, $method], $args); |
|
278 | - foreach ($results as $result) { |
|
279 | - $result['internalPath'] = $result['path']; |
|
280 | - $result['path'] = $relativeMountPoint . $result['path']; |
|
281 | - $result['storage'] = $storage; |
|
282 | - $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, |
|
283 | - $result['internalPath'], $result, $mount); |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
287 | - } |
|
288 | - |
|
289 | - return array_map(function (FileInfo $file) { |
|
290 | - return $this->createNode($file->getPath(), $file); |
|
291 | - }, $files); |
|
292 | - } |
|
293 | - |
|
294 | - /** |
|
295 | - * @param int $id |
|
296 | - * @return \OC\Files\Node\Node[] |
|
297 | - */ |
|
298 | - public function getById($id) { |
|
299 | - $mountCache = $this->root->getUserMountCache(); |
|
300 | - if (strpos($this->getPath(), '/', 1) > 0) { |
|
301 | - list(, $user) = explode('/', $this->getPath()); |
|
302 | - } else { |
|
303 | - $user = null; |
|
304 | - } |
|
305 | - $mountsContainingFile = $mountCache->getMountsForFileId((int)$id, $user); |
|
306 | - $mounts = $this->root->getMountsIn($this->path); |
|
307 | - $mounts[] = $this->root->getMount($this->path); |
|
308 | - /** @var IMountPoint[] $folderMounts */ |
|
309 | - $folderMounts = array_combine(array_map(function (IMountPoint $mountPoint) { |
|
310 | - return $mountPoint->getMountPoint(); |
|
311 | - }, $mounts), $mounts); |
|
312 | - |
|
313 | - /** @var ICachedMountInfo[] $mountsContainingFile */ |
|
314 | - $mountsContainingFile = array_values(array_filter($mountsContainingFile, function (ICachedMountInfo $cachedMountInfo) use ($folderMounts) { |
|
315 | - return isset($folderMounts[$cachedMountInfo->getMountPoint()]); |
|
316 | - })); |
|
317 | - |
|
318 | - if (count($mountsContainingFile) === 0) { |
|
319 | - if ($user === $this->getAppDataDirectoryName()) { |
|
320 | - return $this->getByIdInRootMount((int) $id); |
|
321 | - } |
|
322 | - return []; |
|
323 | - } |
|
324 | - |
|
325 | - $nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($folderMounts, $id) { |
|
326 | - $mount = $folderMounts[$cachedMountInfo->getMountPoint()]; |
|
327 | - $cacheEntry = $mount->getStorage()->getCache()->get((int)$id); |
|
328 | - if (!$cacheEntry) { |
|
329 | - return null; |
|
330 | - } |
|
331 | - |
|
332 | - // cache jails will hide the "true" internal path |
|
333 | - $internalPath = ltrim($cachedMountInfo->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/'); |
|
334 | - $pathRelativeToMount = substr($internalPath, strlen($cachedMountInfo->getRootInternalPath())); |
|
335 | - $pathRelativeToMount = ltrim($pathRelativeToMount, '/'); |
|
336 | - $absolutePath = rtrim($cachedMountInfo->getMountPoint() . $pathRelativeToMount, '/'); |
|
337 | - return $this->root->createNode($absolutePath, new \OC\Files\FileInfo( |
|
338 | - $absolutePath, $mount->getStorage(), $cacheEntry->getPath(), $cacheEntry, $mount, |
|
339 | - \OC::$server->getUserManager()->get($mount->getStorage()->getOwner($pathRelativeToMount)) |
|
340 | - )); |
|
341 | - }, $mountsContainingFile); |
|
342 | - |
|
343 | - $nodes = array_filter($nodes); |
|
344 | - |
|
345 | - return array_filter($nodes, function (Node $node) { |
|
346 | - return $this->getRelativePath($node->getPath()); |
|
347 | - }); |
|
348 | - } |
|
349 | - |
|
350 | - protected function getAppDataDirectoryName(): string { |
|
351 | - $instanceId = \OC::$server->getConfig()->getSystemValueString('instanceid'); |
|
352 | - return 'appdata_' . $instanceId; |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * In case the path we are currently in is inside the appdata_* folder, |
|
357 | - * the original getById method does not work, because it can only look inside |
|
358 | - * the user's mount points. But the user has no mount point for the root storage. |
|
359 | - * |
|
360 | - * So in that case we directly check the mount of the root if it contains |
|
361 | - * the id. If it does we check if the path is inside the path we are working |
|
362 | - * in. |
|
363 | - * |
|
364 | - * @param int $id |
|
365 | - * @return array |
|
366 | - */ |
|
367 | - protected function getByIdInRootMount(int $id): array { |
|
368 | - $mount = $this->root->getMount(''); |
|
369 | - $cacheEntry = $mount->getStorage()->getCache($this->path)->get($id); |
|
370 | - if (!$cacheEntry) { |
|
371 | - return []; |
|
372 | - } |
|
373 | - |
|
374 | - $absolutePath = '/' . ltrim($cacheEntry->getPath(), '/'); |
|
375 | - $currentPath = rtrim($this->path, '/') . '/'; |
|
376 | - |
|
377 | - if (strpos($absolutePath, $currentPath) !== 0) { |
|
378 | - return []; |
|
379 | - } |
|
380 | - |
|
381 | - return [$this->root->createNode( |
|
382 | - $absolutePath, new \OC\Files\FileInfo( |
|
383 | - $absolutePath, |
|
384 | - $mount->getStorage(), |
|
385 | - $cacheEntry->getPath(), |
|
386 | - $cacheEntry, |
|
387 | - $mount |
|
388 | - ))]; |
|
389 | - } |
|
390 | - |
|
391 | - public function getFreeSpace() { |
|
392 | - return $this->view->free_space($this->path); |
|
393 | - } |
|
394 | - |
|
395 | - public function delete() { |
|
396 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
397 | - $this->sendHooks(array('preDelete')); |
|
398 | - $fileInfo = $this->getFileInfo(); |
|
399 | - $this->view->rmdir($this->path); |
|
400 | - $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo); |
|
401 | - $this->sendHooks(['postDelete'], [$nonExisting]); |
|
402 | - $this->exists = false; |
|
403 | - } else { |
|
404 | - throw new NotPermittedException('No delete permission for path'); |
|
405 | - } |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * Add a suffix to the name in case the file exists |
|
410 | - * |
|
411 | - * @param string $name |
|
412 | - * @return string |
|
413 | - * @throws NotPermittedException |
|
414 | - */ |
|
415 | - public function getNonExistingName($name) { |
|
416 | - $uniqueName = \OC_Helper::buildNotExistingFileNameForView($this->getPath(), $name, $this->view); |
|
417 | - return trim($this->getRelativePath($uniqueName), '/'); |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * @param int $limit |
|
422 | - * @param int $offset |
|
423 | - * @return \OCP\Files\Node[] |
|
424 | - */ |
|
425 | - public function getRecent($limit, $offset = 0) { |
|
426 | - $mimetypeLoader = \OC::$server->getMimeTypeLoader(); |
|
427 | - $mounts = $this->root->getMountsIn($this->path); |
|
428 | - $mounts[] = $this->getMountPoint(); |
|
429 | - |
|
430 | - $mounts = array_filter($mounts, function (IMountPoint $mount) { |
|
431 | - return $mount->getStorage(); |
|
432 | - }); |
|
433 | - $storageIds = array_map(function (IMountPoint $mount) { |
|
434 | - return $mount->getStorage()->getCache()->getNumericStorageId(); |
|
435 | - }, $mounts); |
|
436 | - /** @var IMountPoint[] $mountMap */ |
|
437 | - $mountMap = array_combine($storageIds, $mounts); |
|
438 | - $folderMimetype = $mimetypeLoader->getId(FileInfo::MIMETYPE_FOLDER); |
|
439 | - |
|
440 | - // Search in batches of 500 entries |
|
441 | - $searchLimit = 500; |
|
442 | - $results = []; |
|
443 | - $searchResultCount = 0; |
|
444 | - $count = 0; |
|
445 | - do { |
|
446 | - $searchResult = $this->recentSearch($searchLimit, $offset, $storageIds, $folderMimetype); |
|
447 | - |
|
448 | - // Exit condition if there are no more results |
|
449 | - if (count($searchResult) === 0) { |
|
450 | - break; |
|
451 | - } |
|
452 | - |
|
453 | - $searchResultCount += count($searchResult); |
|
454 | - |
|
455 | - $parseResult = $this->recentParse($searchResult, $mountMap, $mimetypeLoader); |
|
456 | - |
|
457 | - foreach ($parseResult as $result) { |
|
458 | - $results[] = $result; |
|
459 | - } |
|
460 | - |
|
461 | - $offset += $searchLimit; |
|
462 | - $count++; |
|
463 | - } while (count($results) < $limit && ($searchResultCount < (3 * $limit) || $count < 5)); |
|
464 | - |
|
465 | - return array_slice($results, 0, $limit); |
|
466 | - } |
|
467 | - |
|
468 | - private function recentSearch($limit, $offset, $storageIds, $folderMimetype) { |
|
469 | - $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
470 | - $query = $builder |
|
471 | - ->select('f.*') |
|
472 | - ->from('filecache', 'f') |
|
473 | - ->andWhere($builder->expr()->in('f.storage', $builder->createNamedParameter($storageIds, IQueryBuilder::PARAM_INT_ARRAY))) |
|
474 | - ->andWhere($builder->expr()->orX( |
|
475 | - // handle non empty folders separate |
|
476 | - $builder->expr()->neq('f.mimetype', $builder->createNamedParameter($folderMimetype, IQueryBuilder::PARAM_INT)), |
|
477 | - $builder->expr()->eq('f.size', new Literal(0)) |
|
478 | - )) |
|
479 | - ->andWhere($builder->expr()->notLike('f.path', $builder->createNamedParameter('files_versions/%'))) |
|
480 | - ->andWhere($builder->expr()->notLike('f.path', $builder->createNamedParameter('files_trashbin/%'))) |
|
481 | - ->orderBy('f.mtime', 'DESC') |
|
482 | - ->setMaxResults($limit) |
|
483 | - ->setFirstResult($offset); |
|
484 | - return $query->execute()->fetchAll(); |
|
485 | - } |
|
486 | - |
|
487 | - private function recentParse($result, $mountMap, $mimetypeLoader) { |
|
488 | - $files = array_filter(array_map(function (array $entry) use ($mountMap, $mimetypeLoader) { |
|
489 | - $mount = $mountMap[$entry['storage']]; |
|
490 | - $entry['internalPath'] = $entry['path']; |
|
491 | - $entry['mimetype'] = $mimetypeLoader->getMimetypeById($entry['mimetype']); |
|
492 | - $entry['mimepart'] = $mimetypeLoader->getMimetypeById($entry['mimepart']); |
|
493 | - $path = $this->getAbsolutePath($mount, $entry['path']); |
|
494 | - if (is_null($path)) { |
|
495 | - return null; |
|
496 | - } |
|
497 | - $fileInfo = new \OC\Files\FileInfo($path, $mount->getStorage(), $entry['internalPath'], $entry, $mount); |
|
498 | - return $this->root->createNode($fileInfo->getPath(), $fileInfo); |
|
499 | - }, $result)); |
|
500 | - |
|
501 | - return array_values(array_filter($files, function (Node $node) { |
|
502 | - $cacheEntry = $node->getMountPoint()->getStorage()->getCache()->get($node->getId()); |
|
503 | - if (!$cacheEntry) { |
|
504 | - return false; |
|
505 | - } |
|
506 | - $relative = $this->getRelativePath($node->getPath()); |
|
507 | - return $relative !== null && $relative !== '/' |
|
508 | - && ($cacheEntry->getPermissions() & \OCP\Constants::PERMISSION_READ) === \OCP\Constants::PERMISSION_READ; |
|
509 | - })); |
|
510 | - } |
|
511 | - |
|
512 | - private function getAbsolutePath(IMountPoint $mount, $path) { |
|
513 | - $storage = $mount->getStorage(); |
|
514 | - if ($storage->instanceOfStorage('\OC\Files\Storage\Wrapper\Jail')) { |
|
515 | - if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
516 | - $storage->getSourceStorage(); |
|
517 | - } |
|
518 | - /** @var \OC\Files\Storage\Wrapper\Jail $storage */ |
|
519 | - $jailRoot = $storage->getUnjailedPath(''); |
|
520 | - $rootLength = strlen($jailRoot) + 1; |
|
521 | - if ($path === $jailRoot) { |
|
522 | - return $mount->getMountPoint(); |
|
523 | - } else if (substr($path, 0, $rootLength) === $jailRoot . '/') { |
|
524 | - return $mount->getMountPoint() . substr($path, $rootLength); |
|
525 | - } else { |
|
526 | - return null; |
|
527 | - } |
|
528 | - } else { |
|
529 | - return $mount->getMountPoint() . $path; |
|
530 | - } |
|
531 | - } |
|
43 | + /** |
|
44 | + * Creates a Folder that represents a non-existing path |
|
45 | + * |
|
46 | + * @param string $path path |
|
47 | + * @return string non-existing node class |
|
48 | + */ |
|
49 | + protected function createNonExistingNode($path) { |
|
50 | + return new NonExistingFolder($this->root, $this->view, $path); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $path path relative to the folder |
|
55 | + * @return string |
|
56 | + * @throws \OCP\Files\NotPermittedException |
|
57 | + */ |
|
58 | + public function getFullPath($path) { |
|
59 | + if (!$this->isValidPath($path)) { |
|
60 | + throw new NotPermittedException('Invalid path'); |
|
61 | + } |
|
62 | + return $this->path . $this->normalizePath($path); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @param string $path |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function getRelativePath($path) { |
|
70 | + if ($this->path === '' or $this->path === '/') { |
|
71 | + return $this->normalizePath($path); |
|
72 | + } |
|
73 | + if ($path === $this->path) { |
|
74 | + return '/'; |
|
75 | + } else if (strpos($path, $this->path . '/') !== 0) { |
|
76 | + return null; |
|
77 | + } else { |
|
78 | + $path = substr($path, strlen($this->path)); |
|
79 | + return $this->normalizePath($path); |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * check if a node is a (grand-)child of the folder |
|
85 | + * |
|
86 | + * @param \OC\Files\Node\Node $node |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function isSubNode($node) { |
|
90 | + return strpos($node->getPath(), $this->path . '/') === 0; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * get the content of this directory |
|
95 | + * |
|
96 | + * @throws \OCP\Files\NotFoundException |
|
97 | + * @return Node[] |
|
98 | + */ |
|
99 | + public function getDirectoryListing() { |
|
100 | + $folderContent = $this->view->getDirectoryContent($this->path); |
|
101 | + |
|
102 | + return array_map(function (FileInfo $info) { |
|
103 | + if ($info->getMimetype() === 'httpd/unix-directory') { |
|
104 | + return new Folder($this->root, $this->view, $info->getPath(), $info); |
|
105 | + } else { |
|
106 | + return new File($this->root, $this->view, $info->getPath(), $info); |
|
107 | + } |
|
108 | + }, $folderContent); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $path |
|
113 | + * @param FileInfo $info |
|
114 | + * @return File|Folder |
|
115 | + */ |
|
116 | + protected function createNode($path, FileInfo $info = null) { |
|
117 | + if (is_null($info)) { |
|
118 | + $isDir = $this->view->is_dir($path); |
|
119 | + } else { |
|
120 | + $isDir = $info->getType() === FileInfo::TYPE_FOLDER; |
|
121 | + } |
|
122 | + if ($isDir) { |
|
123 | + return new Folder($this->root, $this->view, $path, $info); |
|
124 | + } else { |
|
125 | + return new File($this->root, $this->view, $path, $info); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Get the node at $path |
|
131 | + * |
|
132 | + * @param string $path |
|
133 | + * @return \OC\Files\Node\Node |
|
134 | + * @throws \OCP\Files\NotFoundException |
|
135 | + */ |
|
136 | + public function get($path) { |
|
137 | + return $this->root->get($this->getFullPath($path)); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $path |
|
142 | + * @return bool |
|
143 | + */ |
|
144 | + public function nodeExists($path) { |
|
145 | + try { |
|
146 | + $this->get($path); |
|
147 | + return true; |
|
148 | + } catch (NotFoundException $e) { |
|
149 | + return false; |
|
150 | + } |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @param string $path |
|
155 | + * @return \OC\Files\Node\Folder |
|
156 | + * @throws \OCP\Files\NotPermittedException |
|
157 | + */ |
|
158 | + public function newFolder($path) { |
|
159 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { |
|
160 | + $fullPath = $this->getFullPath($path); |
|
161 | + $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); |
|
162 | + $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); |
|
163 | + if(!$this->view->mkdir($fullPath)) { |
|
164 | + throw new NotPermittedException('Could not create folder'); |
|
165 | + } |
|
166 | + $node = new Folder($this->root, $this->view, $fullPath); |
|
167 | + $this->sendHooks(['postWrite', 'postCreate'], [$node]); |
|
168 | + return $node; |
|
169 | + } else { |
|
170 | + throw new NotPermittedException('No create permission for folder'); |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @param string $path |
|
176 | + * @param string | resource | null $content |
|
177 | + * @return \OC\Files\Node\File |
|
178 | + * @throws \OCP\Files\NotPermittedException |
|
179 | + */ |
|
180 | + public function newFile($path, $content = null) { |
|
181 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) { |
|
182 | + $fullPath = $this->getFullPath($path); |
|
183 | + $nonExisting = new NonExistingFile($this->root, $this->view, $fullPath); |
|
184 | + $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); |
|
185 | + if ($content !== null) { |
|
186 | + $result = $this->view->file_put_contents($fullPath, $content); |
|
187 | + } else { |
|
188 | + $result = $this->view->touch($fullPath); |
|
189 | + } |
|
190 | + if (!$result) { |
|
191 | + throw new NotPermittedException('Could not create path'); |
|
192 | + } |
|
193 | + $node = new File($this->root, $this->view, $fullPath); |
|
194 | + $this->sendHooks(['postWrite', 'postCreate'], [$node]); |
|
195 | + return $node; |
|
196 | + } |
|
197 | + throw new NotPermittedException('No create permission for path'); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * search for files with the name matching $query |
|
202 | + * |
|
203 | + * @param string|ISearchQuery $query |
|
204 | + * @return \OC\Files\Node\Node[] |
|
205 | + */ |
|
206 | + public function search($query) { |
|
207 | + if (is_string($query)) { |
|
208 | + return $this->searchCommon('search', array('%' . $query . '%')); |
|
209 | + } else { |
|
210 | + return $this->searchCommon('searchQuery', array($query)); |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * search for files by mimetype |
|
216 | + * |
|
217 | + * @param string $mimetype |
|
218 | + * @return Node[] |
|
219 | + */ |
|
220 | + public function searchByMime($mimetype) { |
|
221 | + return $this->searchCommon('searchByMime', array($mimetype)); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * search for files by tag |
|
226 | + * |
|
227 | + * @param string|int $tag name or tag id |
|
228 | + * @param string $userId owner of the tags |
|
229 | + * @return Node[] |
|
230 | + */ |
|
231 | + public function searchByTag($tag, $userId) { |
|
232 | + return $this->searchCommon('searchByTag', array($tag, $userId)); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * @param string $method cache method |
|
237 | + * @param array $args call args |
|
238 | + * @return \OC\Files\Node\Node[] |
|
239 | + */ |
|
240 | + private function searchCommon($method, $args) { |
|
241 | + $limitToHome = ($method === 'searchQuery')? $args[0]->limitToHome(): false; |
|
242 | + if ($limitToHome && count(explode('/', $this->path)) !== 3) { |
|
243 | + throw new \InvalidArgumentException('searching by owner is only allows on the users home folder'); |
|
244 | + } |
|
245 | + |
|
246 | + $files = array(); |
|
247 | + $rootLength = strlen($this->path); |
|
248 | + $mount = $this->root->getMount($this->path); |
|
249 | + $storage = $mount->getStorage(); |
|
250 | + $internalPath = $mount->getInternalPath($this->path); |
|
251 | + $internalPath = rtrim($internalPath, '/'); |
|
252 | + if ($internalPath !== '') { |
|
253 | + $internalPath = $internalPath . '/'; |
|
254 | + } |
|
255 | + $internalRootLength = strlen($internalPath); |
|
256 | + |
|
257 | + $cache = $storage->getCache(''); |
|
258 | + |
|
259 | + $results = call_user_func_array(array($cache, $method), $args); |
|
260 | + foreach ($results as $result) { |
|
261 | + if ($internalRootLength === 0 or substr($result['path'], 0, $internalRootLength) === $internalPath) { |
|
262 | + $result['internalPath'] = $result['path']; |
|
263 | + $result['path'] = substr($result['path'], $internalRootLength); |
|
264 | + $result['storage'] = $storage; |
|
265 | + $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, $result['internalPath'], $result, $mount); |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + if (!$limitToHome) { |
|
270 | + $mounts = $this->root->getMountsIn($this->path); |
|
271 | + foreach ($mounts as $mount) { |
|
272 | + $storage = $mount->getStorage(); |
|
273 | + if ($storage) { |
|
274 | + $cache = $storage->getCache(''); |
|
275 | + |
|
276 | + $relativeMountPoint = ltrim(substr($mount->getMountPoint(), $rootLength), '/'); |
|
277 | + $results = call_user_func_array([$cache, $method], $args); |
|
278 | + foreach ($results as $result) { |
|
279 | + $result['internalPath'] = $result['path']; |
|
280 | + $result['path'] = $relativeMountPoint . $result['path']; |
|
281 | + $result['storage'] = $storage; |
|
282 | + $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, |
|
283 | + $result['internalPath'], $result, $mount); |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | + } |
|
288 | + |
|
289 | + return array_map(function (FileInfo $file) { |
|
290 | + return $this->createNode($file->getPath(), $file); |
|
291 | + }, $files); |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * @param int $id |
|
296 | + * @return \OC\Files\Node\Node[] |
|
297 | + */ |
|
298 | + public function getById($id) { |
|
299 | + $mountCache = $this->root->getUserMountCache(); |
|
300 | + if (strpos($this->getPath(), '/', 1) > 0) { |
|
301 | + list(, $user) = explode('/', $this->getPath()); |
|
302 | + } else { |
|
303 | + $user = null; |
|
304 | + } |
|
305 | + $mountsContainingFile = $mountCache->getMountsForFileId((int)$id, $user); |
|
306 | + $mounts = $this->root->getMountsIn($this->path); |
|
307 | + $mounts[] = $this->root->getMount($this->path); |
|
308 | + /** @var IMountPoint[] $folderMounts */ |
|
309 | + $folderMounts = array_combine(array_map(function (IMountPoint $mountPoint) { |
|
310 | + return $mountPoint->getMountPoint(); |
|
311 | + }, $mounts), $mounts); |
|
312 | + |
|
313 | + /** @var ICachedMountInfo[] $mountsContainingFile */ |
|
314 | + $mountsContainingFile = array_values(array_filter($mountsContainingFile, function (ICachedMountInfo $cachedMountInfo) use ($folderMounts) { |
|
315 | + return isset($folderMounts[$cachedMountInfo->getMountPoint()]); |
|
316 | + })); |
|
317 | + |
|
318 | + if (count($mountsContainingFile) === 0) { |
|
319 | + if ($user === $this->getAppDataDirectoryName()) { |
|
320 | + return $this->getByIdInRootMount((int) $id); |
|
321 | + } |
|
322 | + return []; |
|
323 | + } |
|
324 | + |
|
325 | + $nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($folderMounts, $id) { |
|
326 | + $mount = $folderMounts[$cachedMountInfo->getMountPoint()]; |
|
327 | + $cacheEntry = $mount->getStorage()->getCache()->get((int)$id); |
|
328 | + if (!$cacheEntry) { |
|
329 | + return null; |
|
330 | + } |
|
331 | + |
|
332 | + // cache jails will hide the "true" internal path |
|
333 | + $internalPath = ltrim($cachedMountInfo->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/'); |
|
334 | + $pathRelativeToMount = substr($internalPath, strlen($cachedMountInfo->getRootInternalPath())); |
|
335 | + $pathRelativeToMount = ltrim($pathRelativeToMount, '/'); |
|
336 | + $absolutePath = rtrim($cachedMountInfo->getMountPoint() . $pathRelativeToMount, '/'); |
|
337 | + return $this->root->createNode($absolutePath, new \OC\Files\FileInfo( |
|
338 | + $absolutePath, $mount->getStorage(), $cacheEntry->getPath(), $cacheEntry, $mount, |
|
339 | + \OC::$server->getUserManager()->get($mount->getStorage()->getOwner($pathRelativeToMount)) |
|
340 | + )); |
|
341 | + }, $mountsContainingFile); |
|
342 | + |
|
343 | + $nodes = array_filter($nodes); |
|
344 | + |
|
345 | + return array_filter($nodes, function (Node $node) { |
|
346 | + return $this->getRelativePath($node->getPath()); |
|
347 | + }); |
|
348 | + } |
|
349 | + |
|
350 | + protected function getAppDataDirectoryName(): string { |
|
351 | + $instanceId = \OC::$server->getConfig()->getSystemValueString('instanceid'); |
|
352 | + return 'appdata_' . $instanceId; |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * In case the path we are currently in is inside the appdata_* folder, |
|
357 | + * the original getById method does not work, because it can only look inside |
|
358 | + * the user's mount points. But the user has no mount point for the root storage. |
|
359 | + * |
|
360 | + * So in that case we directly check the mount of the root if it contains |
|
361 | + * the id. If it does we check if the path is inside the path we are working |
|
362 | + * in. |
|
363 | + * |
|
364 | + * @param int $id |
|
365 | + * @return array |
|
366 | + */ |
|
367 | + protected function getByIdInRootMount(int $id): array { |
|
368 | + $mount = $this->root->getMount(''); |
|
369 | + $cacheEntry = $mount->getStorage()->getCache($this->path)->get($id); |
|
370 | + if (!$cacheEntry) { |
|
371 | + return []; |
|
372 | + } |
|
373 | + |
|
374 | + $absolutePath = '/' . ltrim($cacheEntry->getPath(), '/'); |
|
375 | + $currentPath = rtrim($this->path, '/') . '/'; |
|
376 | + |
|
377 | + if (strpos($absolutePath, $currentPath) !== 0) { |
|
378 | + return []; |
|
379 | + } |
|
380 | + |
|
381 | + return [$this->root->createNode( |
|
382 | + $absolutePath, new \OC\Files\FileInfo( |
|
383 | + $absolutePath, |
|
384 | + $mount->getStorage(), |
|
385 | + $cacheEntry->getPath(), |
|
386 | + $cacheEntry, |
|
387 | + $mount |
|
388 | + ))]; |
|
389 | + } |
|
390 | + |
|
391 | + public function getFreeSpace() { |
|
392 | + return $this->view->free_space($this->path); |
|
393 | + } |
|
394 | + |
|
395 | + public function delete() { |
|
396 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
397 | + $this->sendHooks(array('preDelete')); |
|
398 | + $fileInfo = $this->getFileInfo(); |
|
399 | + $this->view->rmdir($this->path); |
|
400 | + $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo); |
|
401 | + $this->sendHooks(['postDelete'], [$nonExisting]); |
|
402 | + $this->exists = false; |
|
403 | + } else { |
|
404 | + throw new NotPermittedException('No delete permission for path'); |
|
405 | + } |
|
406 | + } |
|
407 | + |
|
408 | + /** |
|
409 | + * Add a suffix to the name in case the file exists |
|
410 | + * |
|
411 | + * @param string $name |
|
412 | + * @return string |
|
413 | + * @throws NotPermittedException |
|
414 | + */ |
|
415 | + public function getNonExistingName($name) { |
|
416 | + $uniqueName = \OC_Helper::buildNotExistingFileNameForView($this->getPath(), $name, $this->view); |
|
417 | + return trim($this->getRelativePath($uniqueName), '/'); |
|
418 | + } |
|
419 | + |
|
420 | + /** |
|
421 | + * @param int $limit |
|
422 | + * @param int $offset |
|
423 | + * @return \OCP\Files\Node[] |
|
424 | + */ |
|
425 | + public function getRecent($limit, $offset = 0) { |
|
426 | + $mimetypeLoader = \OC::$server->getMimeTypeLoader(); |
|
427 | + $mounts = $this->root->getMountsIn($this->path); |
|
428 | + $mounts[] = $this->getMountPoint(); |
|
429 | + |
|
430 | + $mounts = array_filter($mounts, function (IMountPoint $mount) { |
|
431 | + return $mount->getStorage(); |
|
432 | + }); |
|
433 | + $storageIds = array_map(function (IMountPoint $mount) { |
|
434 | + return $mount->getStorage()->getCache()->getNumericStorageId(); |
|
435 | + }, $mounts); |
|
436 | + /** @var IMountPoint[] $mountMap */ |
|
437 | + $mountMap = array_combine($storageIds, $mounts); |
|
438 | + $folderMimetype = $mimetypeLoader->getId(FileInfo::MIMETYPE_FOLDER); |
|
439 | + |
|
440 | + // Search in batches of 500 entries |
|
441 | + $searchLimit = 500; |
|
442 | + $results = []; |
|
443 | + $searchResultCount = 0; |
|
444 | + $count = 0; |
|
445 | + do { |
|
446 | + $searchResult = $this->recentSearch($searchLimit, $offset, $storageIds, $folderMimetype); |
|
447 | + |
|
448 | + // Exit condition if there are no more results |
|
449 | + if (count($searchResult) === 0) { |
|
450 | + break; |
|
451 | + } |
|
452 | + |
|
453 | + $searchResultCount += count($searchResult); |
|
454 | + |
|
455 | + $parseResult = $this->recentParse($searchResult, $mountMap, $mimetypeLoader); |
|
456 | + |
|
457 | + foreach ($parseResult as $result) { |
|
458 | + $results[] = $result; |
|
459 | + } |
|
460 | + |
|
461 | + $offset += $searchLimit; |
|
462 | + $count++; |
|
463 | + } while (count($results) < $limit && ($searchResultCount < (3 * $limit) || $count < 5)); |
|
464 | + |
|
465 | + return array_slice($results, 0, $limit); |
|
466 | + } |
|
467 | + |
|
468 | + private function recentSearch($limit, $offset, $storageIds, $folderMimetype) { |
|
469 | + $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
470 | + $query = $builder |
|
471 | + ->select('f.*') |
|
472 | + ->from('filecache', 'f') |
|
473 | + ->andWhere($builder->expr()->in('f.storage', $builder->createNamedParameter($storageIds, IQueryBuilder::PARAM_INT_ARRAY))) |
|
474 | + ->andWhere($builder->expr()->orX( |
|
475 | + // handle non empty folders separate |
|
476 | + $builder->expr()->neq('f.mimetype', $builder->createNamedParameter($folderMimetype, IQueryBuilder::PARAM_INT)), |
|
477 | + $builder->expr()->eq('f.size', new Literal(0)) |
|
478 | + )) |
|
479 | + ->andWhere($builder->expr()->notLike('f.path', $builder->createNamedParameter('files_versions/%'))) |
|
480 | + ->andWhere($builder->expr()->notLike('f.path', $builder->createNamedParameter('files_trashbin/%'))) |
|
481 | + ->orderBy('f.mtime', 'DESC') |
|
482 | + ->setMaxResults($limit) |
|
483 | + ->setFirstResult($offset); |
|
484 | + return $query->execute()->fetchAll(); |
|
485 | + } |
|
486 | + |
|
487 | + private function recentParse($result, $mountMap, $mimetypeLoader) { |
|
488 | + $files = array_filter(array_map(function (array $entry) use ($mountMap, $mimetypeLoader) { |
|
489 | + $mount = $mountMap[$entry['storage']]; |
|
490 | + $entry['internalPath'] = $entry['path']; |
|
491 | + $entry['mimetype'] = $mimetypeLoader->getMimetypeById($entry['mimetype']); |
|
492 | + $entry['mimepart'] = $mimetypeLoader->getMimetypeById($entry['mimepart']); |
|
493 | + $path = $this->getAbsolutePath($mount, $entry['path']); |
|
494 | + if (is_null($path)) { |
|
495 | + return null; |
|
496 | + } |
|
497 | + $fileInfo = new \OC\Files\FileInfo($path, $mount->getStorage(), $entry['internalPath'], $entry, $mount); |
|
498 | + return $this->root->createNode($fileInfo->getPath(), $fileInfo); |
|
499 | + }, $result)); |
|
500 | + |
|
501 | + return array_values(array_filter($files, function (Node $node) { |
|
502 | + $cacheEntry = $node->getMountPoint()->getStorage()->getCache()->get($node->getId()); |
|
503 | + if (!$cacheEntry) { |
|
504 | + return false; |
|
505 | + } |
|
506 | + $relative = $this->getRelativePath($node->getPath()); |
|
507 | + return $relative !== null && $relative !== '/' |
|
508 | + && ($cacheEntry->getPermissions() & \OCP\Constants::PERMISSION_READ) === \OCP\Constants::PERMISSION_READ; |
|
509 | + })); |
|
510 | + } |
|
511 | + |
|
512 | + private function getAbsolutePath(IMountPoint $mount, $path) { |
|
513 | + $storage = $mount->getStorage(); |
|
514 | + if ($storage->instanceOfStorage('\OC\Files\Storage\Wrapper\Jail')) { |
|
515 | + if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
516 | + $storage->getSourceStorage(); |
|
517 | + } |
|
518 | + /** @var \OC\Files\Storage\Wrapper\Jail $storage */ |
|
519 | + $jailRoot = $storage->getUnjailedPath(''); |
|
520 | + $rootLength = strlen($jailRoot) + 1; |
|
521 | + if ($path === $jailRoot) { |
|
522 | + return $mount->getMountPoint(); |
|
523 | + } else if (substr($path, 0, $rootLength) === $jailRoot . '/') { |
|
524 | + return $mount->getMountPoint() . substr($path, $rootLength); |
|
525 | + } else { |
|
526 | + return null; |
|
527 | + } |
|
528 | + } else { |
|
529 | + return $mount->getMountPoint() . $path; |
|
530 | + } |
|
531 | + } |
|
532 | 532 | } |
@@ -38,156 +38,156 @@ |
||
38 | 38 | * @since 6.0.0 |
39 | 39 | */ |
40 | 40 | interface Folder extends Node { |
41 | - /** |
|
42 | - * Get the full path of an item in the folder within owncloud's filesystem |
|
43 | - * |
|
44 | - * @param string $path relative path of an item in the folder |
|
45 | - * @return string |
|
46 | - * @throws \OCP\Files\NotPermittedException |
|
47 | - * @since 6.0.0 |
|
48 | - */ |
|
49 | - public function getFullPath($path); |
|
50 | - |
|
51 | - /** |
|
52 | - * Get the path of an item in the folder relative to the folder |
|
53 | - * |
|
54 | - * @param string $path absolute path of an item in the folder |
|
55 | - * @throws \OCP\Files\NotFoundException |
|
56 | - * @return string |
|
57 | - * @since 6.0.0 |
|
58 | - */ |
|
59 | - public function getRelativePath($path); |
|
60 | - |
|
61 | - /** |
|
62 | - * check if a node is a (grand-)child of the folder |
|
63 | - * |
|
64 | - * @param \OCP\Files\Node $node |
|
65 | - * @return bool |
|
66 | - * @since 6.0.0 |
|
67 | - */ |
|
68 | - public function isSubNode($node); |
|
69 | - |
|
70 | - /** |
|
71 | - * get the content of this directory |
|
72 | - * |
|
73 | - * @throws \OCP\Files\NotFoundException |
|
74 | - * @return \OCP\Files\Node[] |
|
75 | - * @since 6.0.0 |
|
76 | - */ |
|
77 | - public function getDirectoryListing(); |
|
78 | - |
|
79 | - /** |
|
80 | - * Get the node at $path |
|
81 | - * |
|
82 | - * @param string $path relative path of the file or folder |
|
83 | - * @return \OCP\Files\Node |
|
84 | - * @throws \OCP\Files\NotFoundException |
|
85 | - * @since 6.0.0 |
|
86 | - */ |
|
87 | - public function get($path); |
|
88 | - |
|
89 | - /** |
|
90 | - * Check if a file or folder exists in the folder |
|
91 | - * |
|
92 | - * @param string $path relative path of the file or folder |
|
93 | - * @return bool |
|
94 | - * @since 6.0.0 |
|
95 | - */ |
|
96 | - public function nodeExists($path); |
|
97 | - |
|
98 | - /** |
|
99 | - * Create a new folder |
|
100 | - * |
|
101 | - * @param string $path relative path of the new folder |
|
102 | - * @return \OCP\Files\Folder |
|
103 | - * @throws \OCP\Files\NotPermittedException |
|
104 | - * @since 6.0.0 |
|
105 | - */ |
|
106 | - public function newFolder($path); |
|
107 | - |
|
108 | - /** |
|
109 | - * Create a new file |
|
110 | - * |
|
111 | - * @param string $path relative path of the new file |
|
112 | - * @param string|resource|null $content content for the new file, since 19.0.0 |
|
113 | - * @return \OCP\Files\File |
|
114 | - * @throws \OCP\Files\NotPermittedException |
|
115 | - * @since 6.0.0 |
|
116 | - */ |
|
117 | - public function newFile($path, $content = null); |
|
118 | - |
|
119 | - /** |
|
120 | - * search for files with the name matching $query |
|
121 | - * |
|
122 | - * @param string|ISearchQuery $query |
|
123 | - * @return \OCP\Files\Node[] |
|
124 | - * @since 6.0.0 |
|
125 | - */ |
|
126 | - public function search($query); |
|
127 | - |
|
128 | - /** |
|
129 | - * search for files by mimetype |
|
130 | - * $mimetype can either be a full mimetype (image/png) or a wildcard mimetype (image) |
|
131 | - * |
|
132 | - * @param string $mimetype |
|
133 | - * @return \OCP\Files\Node[] |
|
134 | - * @since 6.0.0 |
|
135 | - */ |
|
136 | - public function searchByMime($mimetype); |
|
137 | - |
|
138 | - /** |
|
139 | - * search for files by tag |
|
140 | - * |
|
141 | - * @param string|int $tag tag name or tag id |
|
142 | - * @param string $userId owner of the tags |
|
143 | - * @return \OCP\Files\Node[] |
|
144 | - * @since 8.0.0 |
|
145 | - */ |
|
146 | - public function searchByTag($tag, $userId); |
|
147 | - |
|
148 | - /** |
|
149 | - * get a file or folder inside the folder by it's internal id |
|
150 | - * |
|
151 | - * This method could return multiple entries. For example once the file/folder |
|
152 | - * is shared or mounted (files_external) to the user multiple times. |
|
153 | - * |
|
154 | - * @param int $id |
|
155 | - * @return \OCP\Files\Node[] |
|
156 | - * @since 6.0.0 |
|
157 | - */ |
|
158 | - public function getById($id); |
|
159 | - |
|
160 | - /** |
|
161 | - * Get the amount of free space inside the folder |
|
162 | - * |
|
163 | - * @return int |
|
164 | - * @since 6.0.0 |
|
165 | - */ |
|
166 | - public function getFreeSpace(); |
|
167 | - |
|
168 | - /** |
|
169 | - * Check if new files or folders can be created within the folder |
|
170 | - * |
|
171 | - * @return bool |
|
172 | - * @since 6.0.0 |
|
173 | - */ |
|
174 | - public function isCreatable(); |
|
175 | - |
|
176 | - /** |
|
177 | - * Add a suffix to the name in case the file exists |
|
178 | - * |
|
179 | - * @param string $name |
|
180 | - * @return string |
|
181 | - * @throws NotPermittedException |
|
182 | - * @since 8.1.0 |
|
183 | - */ |
|
184 | - public function getNonExistingName($name); |
|
185 | - |
|
186 | - /** |
|
187 | - * @param int $limit |
|
188 | - * @param int $offset |
|
189 | - * @return \OCP\Files\Node[] |
|
190 | - * @since 9.1.0 |
|
191 | - */ |
|
192 | - public function getRecent($limit, $offset = 0); |
|
41 | + /** |
|
42 | + * Get the full path of an item in the folder within owncloud's filesystem |
|
43 | + * |
|
44 | + * @param string $path relative path of an item in the folder |
|
45 | + * @return string |
|
46 | + * @throws \OCP\Files\NotPermittedException |
|
47 | + * @since 6.0.0 |
|
48 | + */ |
|
49 | + public function getFullPath($path); |
|
50 | + |
|
51 | + /** |
|
52 | + * Get the path of an item in the folder relative to the folder |
|
53 | + * |
|
54 | + * @param string $path absolute path of an item in the folder |
|
55 | + * @throws \OCP\Files\NotFoundException |
|
56 | + * @return string |
|
57 | + * @since 6.0.0 |
|
58 | + */ |
|
59 | + public function getRelativePath($path); |
|
60 | + |
|
61 | + /** |
|
62 | + * check if a node is a (grand-)child of the folder |
|
63 | + * |
|
64 | + * @param \OCP\Files\Node $node |
|
65 | + * @return bool |
|
66 | + * @since 6.0.0 |
|
67 | + */ |
|
68 | + public function isSubNode($node); |
|
69 | + |
|
70 | + /** |
|
71 | + * get the content of this directory |
|
72 | + * |
|
73 | + * @throws \OCP\Files\NotFoundException |
|
74 | + * @return \OCP\Files\Node[] |
|
75 | + * @since 6.0.0 |
|
76 | + */ |
|
77 | + public function getDirectoryListing(); |
|
78 | + |
|
79 | + /** |
|
80 | + * Get the node at $path |
|
81 | + * |
|
82 | + * @param string $path relative path of the file or folder |
|
83 | + * @return \OCP\Files\Node |
|
84 | + * @throws \OCP\Files\NotFoundException |
|
85 | + * @since 6.0.0 |
|
86 | + */ |
|
87 | + public function get($path); |
|
88 | + |
|
89 | + /** |
|
90 | + * Check if a file or folder exists in the folder |
|
91 | + * |
|
92 | + * @param string $path relative path of the file or folder |
|
93 | + * @return bool |
|
94 | + * @since 6.0.0 |
|
95 | + */ |
|
96 | + public function nodeExists($path); |
|
97 | + |
|
98 | + /** |
|
99 | + * Create a new folder |
|
100 | + * |
|
101 | + * @param string $path relative path of the new folder |
|
102 | + * @return \OCP\Files\Folder |
|
103 | + * @throws \OCP\Files\NotPermittedException |
|
104 | + * @since 6.0.0 |
|
105 | + */ |
|
106 | + public function newFolder($path); |
|
107 | + |
|
108 | + /** |
|
109 | + * Create a new file |
|
110 | + * |
|
111 | + * @param string $path relative path of the new file |
|
112 | + * @param string|resource|null $content content for the new file, since 19.0.0 |
|
113 | + * @return \OCP\Files\File |
|
114 | + * @throws \OCP\Files\NotPermittedException |
|
115 | + * @since 6.0.0 |
|
116 | + */ |
|
117 | + public function newFile($path, $content = null); |
|
118 | + |
|
119 | + /** |
|
120 | + * search for files with the name matching $query |
|
121 | + * |
|
122 | + * @param string|ISearchQuery $query |
|
123 | + * @return \OCP\Files\Node[] |
|
124 | + * @since 6.0.0 |
|
125 | + */ |
|
126 | + public function search($query); |
|
127 | + |
|
128 | + /** |
|
129 | + * search for files by mimetype |
|
130 | + * $mimetype can either be a full mimetype (image/png) or a wildcard mimetype (image) |
|
131 | + * |
|
132 | + * @param string $mimetype |
|
133 | + * @return \OCP\Files\Node[] |
|
134 | + * @since 6.0.0 |
|
135 | + */ |
|
136 | + public function searchByMime($mimetype); |
|
137 | + |
|
138 | + /** |
|
139 | + * search for files by tag |
|
140 | + * |
|
141 | + * @param string|int $tag tag name or tag id |
|
142 | + * @param string $userId owner of the tags |
|
143 | + * @return \OCP\Files\Node[] |
|
144 | + * @since 8.0.0 |
|
145 | + */ |
|
146 | + public function searchByTag($tag, $userId); |
|
147 | + |
|
148 | + /** |
|
149 | + * get a file or folder inside the folder by it's internal id |
|
150 | + * |
|
151 | + * This method could return multiple entries. For example once the file/folder |
|
152 | + * is shared or mounted (files_external) to the user multiple times. |
|
153 | + * |
|
154 | + * @param int $id |
|
155 | + * @return \OCP\Files\Node[] |
|
156 | + * @since 6.0.0 |
|
157 | + */ |
|
158 | + public function getById($id); |
|
159 | + |
|
160 | + /** |
|
161 | + * Get the amount of free space inside the folder |
|
162 | + * |
|
163 | + * @return int |
|
164 | + * @since 6.0.0 |
|
165 | + */ |
|
166 | + public function getFreeSpace(); |
|
167 | + |
|
168 | + /** |
|
169 | + * Check if new files or folders can be created within the folder |
|
170 | + * |
|
171 | + * @return bool |
|
172 | + * @since 6.0.0 |
|
173 | + */ |
|
174 | + public function isCreatable(); |
|
175 | + |
|
176 | + /** |
|
177 | + * Add a suffix to the name in case the file exists |
|
178 | + * |
|
179 | + * @param string $name |
|
180 | + * @return string |
|
181 | + * @throws NotPermittedException |
|
182 | + * @since 8.1.0 |
|
183 | + */ |
|
184 | + public function getNonExistingName($name); |
|
185 | + |
|
186 | + /** |
|
187 | + * @param int $limit |
|
188 | + * @param int $offset |
|
189 | + * @return \OCP\Files\Node[] |
|
190 | + * @since 9.1.0 |
|
191 | + */ |
|
192 | + public function getRecent($limit, $offset = 0); |
|
193 | 193 | } |
@@ -33,57 +33,57 @@ |
||
33 | 33 | * @since 11.0.0 |
34 | 34 | */ |
35 | 35 | interface ISimpleFolder { |
36 | - /** |
|
37 | - * Get all the files in a folder |
|
38 | - * |
|
39 | - * @return ISimpleFile[] |
|
40 | - * @since 11.0.0 |
|
41 | - */ |
|
42 | - public function getDirectoryListing(); |
|
36 | + /** |
|
37 | + * Get all the files in a folder |
|
38 | + * |
|
39 | + * @return ISimpleFile[] |
|
40 | + * @since 11.0.0 |
|
41 | + */ |
|
42 | + public function getDirectoryListing(); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Check if a file with $name exists |
|
46 | - * |
|
47 | - * @param string $name |
|
48 | - * @return bool |
|
49 | - * @since 11.0.0 |
|
50 | - */ |
|
51 | - public function fileExists($name); |
|
44 | + /** |
|
45 | + * Check if a file with $name exists |
|
46 | + * |
|
47 | + * @param string $name |
|
48 | + * @return bool |
|
49 | + * @since 11.0.0 |
|
50 | + */ |
|
51 | + public function fileExists($name); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Get the file named $name from the folder |
|
55 | - * |
|
56 | - * @param string $name |
|
57 | - * @return ISimpleFile |
|
58 | - * @throws NotFoundException |
|
59 | - * @since 11.0.0 |
|
60 | - */ |
|
61 | - public function getFile($name); |
|
53 | + /** |
|
54 | + * Get the file named $name from the folder |
|
55 | + * |
|
56 | + * @param string $name |
|
57 | + * @return ISimpleFile |
|
58 | + * @throws NotFoundException |
|
59 | + * @since 11.0.0 |
|
60 | + */ |
|
61 | + public function getFile($name); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Creates a new file with $name in the folder |
|
65 | - * |
|
66 | - * @param string $name |
|
67 | - * @param string|resource|null $content @since 19.0.0 |
|
68 | - * @return ISimpleFile |
|
69 | - * @throws NotPermittedException |
|
70 | - * @since 11.0.0 |
|
71 | - */ |
|
72 | - public function newFile($name, $content = null); |
|
63 | + /** |
|
64 | + * Creates a new file with $name in the folder |
|
65 | + * |
|
66 | + * @param string $name |
|
67 | + * @param string|resource|null $content @since 19.0.0 |
|
68 | + * @return ISimpleFile |
|
69 | + * @throws NotPermittedException |
|
70 | + * @since 11.0.0 |
|
71 | + */ |
|
72 | + public function newFile($name, $content = null); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Remove the folder and all the files in it |
|
76 | - * |
|
77 | - * @throws NotPermittedException |
|
78 | - * @since 11.0.0 |
|
79 | - */ |
|
80 | - public function delete(); |
|
74 | + /** |
|
75 | + * Remove the folder and all the files in it |
|
76 | + * |
|
77 | + * @throws NotPermittedException |
|
78 | + * @since 11.0.0 |
|
79 | + */ |
|
80 | + public function delete(); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Get the folder name |
|
84 | - * |
|
85 | - * @return string |
|
86 | - * @since 11.0.0 |
|
87 | - */ |
|
88 | - public function getName(); |
|
82 | + /** |
|
83 | + * Get the folder name |
|
84 | + * |
|
85 | + * @return string |
|
86 | + * @since 11.0.0 |
|
87 | + */ |
|
88 | + public function getName(); |
|
89 | 89 | } |