@@ -29,113 +29,113 @@ |
||
29 | 29 | use OCP\Files\NotPermittedException; |
30 | 30 | |
31 | 31 | class File extends Node implements \OCP\Files\File { |
32 | - /** |
|
33 | - * Creates a Folder that represents a non-existing path |
|
34 | - * |
|
35 | - * @param string $path path |
|
36 | - * @return string non-existing node class |
|
37 | - */ |
|
38 | - protected function createNonExistingNode($path) { |
|
39 | - return new NonExistingFile($this->root, $this->view, $path); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Creates a Folder that represents a non-existing path |
|
34 | + * |
|
35 | + * @param string $path path |
|
36 | + * @return string non-existing node class |
|
37 | + */ |
|
38 | + protected function createNonExistingNode($path) { |
|
39 | + return new NonExistingFile($this->root, $this->view, $path); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - * @throws \OCP\Files\NotPermittedException |
|
45 | - */ |
|
46 | - public function getContent() { |
|
47 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { |
|
48 | - /** |
|
49 | - * @var \OC\Files\Storage\Storage $storage; |
|
50 | - */ |
|
51 | - return $this->view->file_get_contents($this->path); |
|
52 | - } else { |
|
53 | - throw new NotPermittedException(); |
|
54 | - } |
|
55 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + * @throws \OCP\Files\NotPermittedException |
|
45 | + */ |
|
46 | + public function getContent() { |
|
47 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { |
|
48 | + /** |
|
49 | + * @var \OC\Files\Storage\Storage $storage; |
|
50 | + */ |
|
51 | + return $this->view->file_get_contents($this->path); |
|
52 | + } else { |
|
53 | + throw new NotPermittedException(); |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $data |
|
59 | - * @throws \OCP\Files\NotPermittedException |
|
60 | - */ |
|
61 | - public function putContent($data) { |
|
62 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { |
|
63 | - $this->sendHooks(array('preWrite')); |
|
64 | - $this->view->file_put_contents($this->path, $data); |
|
65 | - $this->fileInfo = null; |
|
66 | - $this->sendHooks(array('postWrite')); |
|
67 | - } else { |
|
68 | - throw new NotPermittedException(); |
|
69 | - } |
|
70 | - } |
|
57 | + /** |
|
58 | + * @param string $data |
|
59 | + * @throws \OCP\Files\NotPermittedException |
|
60 | + */ |
|
61 | + public function putContent($data) { |
|
62 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { |
|
63 | + $this->sendHooks(array('preWrite')); |
|
64 | + $this->view->file_put_contents($this->path, $data); |
|
65 | + $this->fileInfo = null; |
|
66 | + $this->sendHooks(array('postWrite')); |
|
67 | + } else { |
|
68 | + throw new NotPermittedException(); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param string $mode |
|
74 | - * @return resource |
|
75 | - * @throws \OCP\Files\NotPermittedException |
|
76 | - */ |
|
77 | - public function fopen($mode) { |
|
78 | - $preHooks = array(); |
|
79 | - $postHooks = array(); |
|
80 | - $requiredPermissions = \OCP\Constants::PERMISSION_READ; |
|
81 | - switch ($mode) { |
|
82 | - case 'r+': |
|
83 | - case 'rb+': |
|
84 | - case 'w+': |
|
85 | - case 'wb+': |
|
86 | - case 'x+': |
|
87 | - case 'xb+': |
|
88 | - case 'a+': |
|
89 | - case 'ab+': |
|
90 | - case 'w': |
|
91 | - case 'wb': |
|
92 | - case 'x': |
|
93 | - case 'xb': |
|
94 | - case 'a': |
|
95 | - case 'ab': |
|
96 | - $preHooks[] = 'preWrite'; |
|
97 | - $postHooks[] = 'postWrite'; |
|
98 | - $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; |
|
99 | - break; |
|
100 | - } |
|
72 | + /** |
|
73 | + * @param string $mode |
|
74 | + * @return resource |
|
75 | + * @throws \OCP\Files\NotPermittedException |
|
76 | + */ |
|
77 | + public function fopen($mode) { |
|
78 | + $preHooks = array(); |
|
79 | + $postHooks = array(); |
|
80 | + $requiredPermissions = \OCP\Constants::PERMISSION_READ; |
|
81 | + switch ($mode) { |
|
82 | + case 'r+': |
|
83 | + case 'rb+': |
|
84 | + case 'w+': |
|
85 | + case 'wb+': |
|
86 | + case 'x+': |
|
87 | + case 'xb+': |
|
88 | + case 'a+': |
|
89 | + case 'ab+': |
|
90 | + case 'w': |
|
91 | + case 'wb': |
|
92 | + case 'x': |
|
93 | + case 'xb': |
|
94 | + case 'a': |
|
95 | + case 'ab': |
|
96 | + $preHooks[] = 'preWrite'; |
|
97 | + $postHooks[] = 'postWrite'; |
|
98 | + $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; |
|
99 | + break; |
|
100 | + } |
|
101 | 101 | |
102 | - if ($this->checkPermissions($requiredPermissions)) { |
|
103 | - $this->sendHooks($preHooks); |
|
104 | - $result = $this->view->fopen($this->path, $mode); |
|
105 | - $this->sendHooks($postHooks); |
|
106 | - return $result; |
|
107 | - } else { |
|
108 | - throw new NotPermittedException(); |
|
109 | - } |
|
110 | - } |
|
102 | + if ($this->checkPermissions($requiredPermissions)) { |
|
103 | + $this->sendHooks($preHooks); |
|
104 | + $result = $this->view->fopen($this->path, $mode); |
|
105 | + $this->sendHooks($postHooks); |
|
106 | + return $result; |
|
107 | + } else { |
|
108 | + throw new NotPermittedException(); |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | - public function delete() { |
|
113 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
114 | - $this->sendHooks(array('preDelete')); |
|
115 | - $fileInfo = $this->getFileInfo(); |
|
116 | - $this->view->unlink($this->path); |
|
117 | - $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); |
|
118 | - $this->root->emit('\OC\Files', 'postDelete', array($nonExisting)); |
|
119 | - $this->exists = false; |
|
120 | - $this->fileInfo = null; |
|
121 | - } else { |
|
122 | - throw new NotPermittedException(); |
|
123 | - } |
|
124 | - } |
|
112 | + public function delete() { |
|
113 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
114 | + $this->sendHooks(array('preDelete')); |
|
115 | + $fileInfo = $this->getFileInfo(); |
|
116 | + $this->view->unlink($this->path); |
|
117 | + $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); |
|
118 | + $this->root->emit('\OC\Files', 'postDelete', array($nonExisting)); |
|
119 | + $this->exists = false; |
|
120 | + $this->fileInfo = null; |
|
121 | + } else { |
|
122 | + throw new NotPermittedException(); |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @param string $type |
|
128 | - * @param bool $raw |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function hash($type, $raw = false) { |
|
132 | - return $this->view->hash($type, $this->path, $raw); |
|
133 | - } |
|
126 | + /** |
|
127 | + * @param string $type |
|
128 | + * @param bool $raw |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function hash($type, $raw = false) { |
|
132 | + return $this->view->hash($type, $this->path, $raw); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @inheritdoc |
|
137 | - */ |
|
138 | - public function getChecksum() { |
|
139 | - return $this->getFileInfo()->getChecksum(); |
|
140 | - } |
|
135 | + /** |
|
136 | + * @inheritdoc |
|
137 | + */ |
|
138 | + public function getChecksum() { |
|
139 | + return $this->getFileInfo()->getChecksum(); |
|
140 | + } |
|
141 | 141 | } |
@@ -28,138 +28,138 @@ |
||
28 | 28 | use OCP\Util; |
29 | 29 | |
30 | 30 | class HookConnector { |
31 | - /** |
|
32 | - * @var Root |
|
33 | - */ |
|
34 | - private $root; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var View |
|
38 | - */ |
|
39 | - private $view; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var FileInfo[] |
|
43 | - */ |
|
44 | - private $deleteMetaCache = []; |
|
45 | - |
|
46 | - /** |
|
47 | - * HookConnector constructor. |
|
48 | - * |
|
49 | - * @param Root $root |
|
50 | - * @param View $view |
|
51 | - */ |
|
52 | - public function __construct(Root $root, View $view) { |
|
53 | - $this->root = $root; |
|
54 | - $this->view = $view; |
|
55 | - } |
|
56 | - |
|
57 | - public function viewToNode() { |
|
58 | - Util::connectHook('OC_Filesystem', 'write', $this, 'write'); |
|
59 | - Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite'); |
|
60 | - |
|
61 | - Util::connectHook('OC_Filesystem', 'create', $this, 'create'); |
|
62 | - Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate'); |
|
63 | - |
|
64 | - Util::connectHook('OC_Filesystem', 'delete', $this, 'delete'); |
|
65 | - Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete'); |
|
66 | - |
|
67 | - Util::connectHook('OC_Filesystem', 'rename', $this, 'rename'); |
|
68 | - Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename'); |
|
69 | - |
|
70 | - Util::connectHook('OC_Filesystem', 'copy', $this, 'copy'); |
|
71 | - Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy'); |
|
72 | - |
|
73 | - Util::connectHook('OC_Filesystem', 'touch', $this, 'touch'); |
|
74 | - Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch'); |
|
75 | - } |
|
76 | - |
|
77 | - public function write($arguments) { |
|
78 | - $node = $this->getNodeForPath($arguments['path']); |
|
79 | - $this->root->emit('\OC\Files', 'preWrite', [$node]); |
|
80 | - } |
|
81 | - |
|
82 | - public function postWrite($arguments) { |
|
83 | - $node = $this->getNodeForPath($arguments['path']); |
|
84 | - $this->root->emit('\OC\Files', 'postWrite', [$node]); |
|
85 | - } |
|
86 | - |
|
87 | - public function create($arguments) { |
|
88 | - $node = $this->getNodeForPath($arguments['path']); |
|
89 | - $this->root->emit('\OC\Files', 'preCreate', [$node]); |
|
90 | - } |
|
91 | - |
|
92 | - public function postCreate($arguments) { |
|
93 | - $node = $this->getNodeForPath($arguments['path']); |
|
94 | - $this->root->emit('\OC\Files', 'postCreate', [$node]); |
|
95 | - } |
|
96 | - |
|
97 | - public function delete($arguments) { |
|
98 | - $node = $this->getNodeForPath($arguments['path']); |
|
99 | - $this->deleteMetaCache[$node->getPath()] = $node->getFileInfo(); |
|
100 | - $this->root->emit('\OC\Files', 'preDelete', [$node]); |
|
101 | - } |
|
102 | - |
|
103 | - public function postDelete($arguments) { |
|
104 | - $node = $this->getNodeForPath($arguments['path']); |
|
105 | - unset($this->deleteMetaCache[$node->getPath()]); |
|
106 | - $this->root->emit('\OC\Files', 'postDelete', [$node]); |
|
107 | - } |
|
108 | - |
|
109 | - public function touch($arguments) { |
|
110 | - $node = $this->getNodeForPath($arguments['path']); |
|
111 | - $this->root->emit('\OC\Files', 'preTouch', [$node]); |
|
112 | - } |
|
113 | - |
|
114 | - public function postTouch($arguments) { |
|
115 | - $node = $this->getNodeForPath($arguments['path']); |
|
116 | - $this->root->emit('\OC\Files', 'postTouch', [$node]); |
|
117 | - } |
|
118 | - |
|
119 | - public function rename($arguments) { |
|
120 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
121 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
122 | - $this->root->emit('\OC\Files', 'preRename', [$source, $target]); |
|
123 | - } |
|
124 | - |
|
125 | - public function postRename($arguments) { |
|
126 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
127 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
128 | - $this->root->emit('\OC\Files', 'postRename', [$source, $target]); |
|
129 | - } |
|
130 | - |
|
131 | - public function copy($arguments) { |
|
132 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
133 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
134 | - $this->root->emit('\OC\Files', 'preCopy', [$source, $target]); |
|
135 | - } |
|
136 | - |
|
137 | - public function postCopy($arguments) { |
|
138 | - $source = $this->getNodeForPath($arguments['oldpath']); |
|
139 | - $target = $this->getNodeForPath($arguments['newpath']); |
|
140 | - $this->root->emit('\OC\Files', 'postCopy', [$source, $target]); |
|
141 | - } |
|
142 | - |
|
143 | - private function getNodeForPath($path) { |
|
144 | - $info = Filesystem::getView()->getFileInfo($path); |
|
145 | - if (!$info) { |
|
146 | - |
|
147 | - $fullPath = Filesystem::getView()->getAbsolutePath($path); |
|
148 | - if (isset($this->deleteMetaCache[$fullPath])) { |
|
149 | - $info = $this->deleteMetaCache[$fullPath]; |
|
150 | - } else { |
|
151 | - $info = null; |
|
152 | - } |
|
153 | - if (Filesystem::is_dir($path)) { |
|
154 | - return new NonExistingFolder($this->root, $this->view, $fullPath, $info); |
|
155 | - } else { |
|
156 | - return new NonExistingFile($this->root, $this->view, $fullPath, $info); |
|
157 | - } |
|
158 | - } |
|
159 | - if ($info->getType() === FileInfo::TYPE_FILE) { |
|
160 | - return new File($this->root, $this->view, $info->getPath(), $info); |
|
161 | - } else { |
|
162 | - return new Folder($this->root, $this->view, $info->getPath(), $info); |
|
163 | - } |
|
164 | - } |
|
31 | + /** |
|
32 | + * @var Root |
|
33 | + */ |
|
34 | + private $root; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var View |
|
38 | + */ |
|
39 | + private $view; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var FileInfo[] |
|
43 | + */ |
|
44 | + private $deleteMetaCache = []; |
|
45 | + |
|
46 | + /** |
|
47 | + * HookConnector constructor. |
|
48 | + * |
|
49 | + * @param Root $root |
|
50 | + * @param View $view |
|
51 | + */ |
|
52 | + public function __construct(Root $root, View $view) { |
|
53 | + $this->root = $root; |
|
54 | + $this->view = $view; |
|
55 | + } |
|
56 | + |
|
57 | + public function viewToNode() { |
|
58 | + Util::connectHook('OC_Filesystem', 'write', $this, 'write'); |
|
59 | + Util::connectHook('OC_Filesystem', 'post_write', $this, 'postWrite'); |
|
60 | + |
|
61 | + Util::connectHook('OC_Filesystem', 'create', $this, 'create'); |
|
62 | + Util::connectHook('OC_Filesystem', 'post_create', $this, 'postCreate'); |
|
63 | + |
|
64 | + Util::connectHook('OC_Filesystem', 'delete', $this, 'delete'); |
|
65 | + Util::connectHook('OC_Filesystem', 'post_delete', $this, 'postDelete'); |
|
66 | + |
|
67 | + Util::connectHook('OC_Filesystem', 'rename', $this, 'rename'); |
|
68 | + Util::connectHook('OC_Filesystem', 'post_rename', $this, 'postRename'); |
|
69 | + |
|
70 | + Util::connectHook('OC_Filesystem', 'copy', $this, 'copy'); |
|
71 | + Util::connectHook('OC_Filesystem', 'post_copy', $this, 'postCopy'); |
|
72 | + |
|
73 | + Util::connectHook('OC_Filesystem', 'touch', $this, 'touch'); |
|
74 | + Util::connectHook('OC_Filesystem', 'post_touch', $this, 'postTouch'); |
|
75 | + } |
|
76 | + |
|
77 | + public function write($arguments) { |
|
78 | + $node = $this->getNodeForPath($arguments['path']); |
|
79 | + $this->root->emit('\OC\Files', 'preWrite', [$node]); |
|
80 | + } |
|
81 | + |
|
82 | + public function postWrite($arguments) { |
|
83 | + $node = $this->getNodeForPath($arguments['path']); |
|
84 | + $this->root->emit('\OC\Files', 'postWrite', [$node]); |
|
85 | + } |
|
86 | + |
|
87 | + public function create($arguments) { |
|
88 | + $node = $this->getNodeForPath($arguments['path']); |
|
89 | + $this->root->emit('\OC\Files', 'preCreate', [$node]); |
|
90 | + } |
|
91 | + |
|
92 | + public function postCreate($arguments) { |
|
93 | + $node = $this->getNodeForPath($arguments['path']); |
|
94 | + $this->root->emit('\OC\Files', 'postCreate', [$node]); |
|
95 | + } |
|
96 | + |
|
97 | + public function delete($arguments) { |
|
98 | + $node = $this->getNodeForPath($arguments['path']); |
|
99 | + $this->deleteMetaCache[$node->getPath()] = $node->getFileInfo(); |
|
100 | + $this->root->emit('\OC\Files', 'preDelete', [$node]); |
|
101 | + } |
|
102 | + |
|
103 | + public function postDelete($arguments) { |
|
104 | + $node = $this->getNodeForPath($arguments['path']); |
|
105 | + unset($this->deleteMetaCache[$node->getPath()]); |
|
106 | + $this->root->emit('\OC\Files', 'postDelete', [$node]); |
|
107 | + } |
|
108 | + |
|
109 | + public function touch($arguments) { |
|
110 | + $node = $this->getNodeForPath($arguments['path']); |
|
111 | + $this->root->emit('\OC\Files', 'preTouch', [$node]); |
|
112 | + } |
|
113 | + |
|
114 | + public function postTouch($arguments) { |
|
115 | + $node = $this->getNodeForPath($arguments['path']); |
|
116 | + $this->root->emit('\OC\Files', 'postTouch', [$node]); |
|
117 | + } |
|
118 | + |
|
119 | + public function rename($arguments) { |
|
120 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
121 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
122 | + $this->root->emit('\OC\Files', 'preRename', [$source, $target]); |
|
123 | + } |
|
124 | + |
|
125 | + public function postRename($arguments) { |
|
126 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
127 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
128 | + $this->root->emit('\OC\Files', 'postRename', [$source, $target]); |
|
129 | + } |
|
130 | + |
|
131 | + public function copy($arguments) { |
|
132 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
133 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
134 | + $this->root->emit('\OC\Files', 'preCopy', [$source, $target]); |
|
135 | + } |
|
136 | + |
|
137 | + public function postCopy($arguments) { |
|
138 | + $source = $this->getNodeForPath($arguments['oldpath']); |
|
139 | + $target = $this->getNodeForPath($arguments['newpath']); |
|
140 | + $this->root->emit('\OC\Files', 'postCopy', [$source, $target]); |
|
141 | + } |
|
142 | + |
|
143 | + private function getNodeForPath($path) { |
|
144 | + $info = Filesystem::getView()->getFileInfo($path); |
|
145 | + if (!$info) { |
|
146 | + |
|
147 | + $fullPath = Filesystem::getView()->getAbsolutePath($path); |
|
148 | + if (isset($this->deleteMetaCache[$fullPath])) { |
|
149 | + $info = $this->deleteMetaCache[$fullPath]; |
|
150 | + } else { |
|
151 | + $info = null; |
|
152 | + } |
|
153 | + if (Filesystem::is_dir($path)) { |
|
154 | + return new NonExistingFolder($this->root, $this->view, $fullPath, $info); |
|
155 | + } else { |
|
156 | + return new NonExistingFile($this->root, $this->view, $fullPath, $info); |
|
157 | + } |
|
158 | + } |
|
159 | + if ($info->getType() === FileInfo::TYPE_FILE) { |
|
160 | + return new File($this->root, $this->view, $info->getPath(), $info); |
|
161 | + } else { |
|
162 | + return new Folder($this->root, $this->view, $info->getPath(), $info); |
|
163 | + } |
|
164 | + } |
|
165 | 165 | } |
@@ -26,119 +26,119 @@ |
||
26 | 26 | use OCP\Files\NotFoundException; |
27 | 27 | |
28 | 28 | class NonExistingFile extends File { |
29 | - /** |
|
30 | - * @param string $newPath |
|
31 | - * @throws \OCP\Files\NotFoundException |
|
32 | - */ |
|
33 | - public function rename($newPath) { |
|
34 | - throw new NotFoundException(); |
|
35 | - } |
|
36 | - |
|
37 | - public function delete() { |
|
38 | - throw new NotFoundException(); |
|
39 | - } |
|
40 | - |
|
41 | - public function copy($newPath) { |
|
42 | - throw new NotFoundException(); |
|
43 | - } |
|
44 | - |
|
45 | - public function touch($mtime = null) { |
|
46 | - throw new NotFoundException(); |
|
47 | - } |
|
48 | - |
|
49 | - public function getId() { |
|
50 | - if ($this->fileInfo) { |
|
51 | - return parent::getId(); |
|
52 | - } else { |
|
53 | - throw new NotFoundException(); |
|
54 | - } |
|
55 | - } |
|
56 | - |
|
57 | - public function stat() { |
|
58 | - throw new NotFoundException(); |
|
59 | - } |
|
60 | - |
|
61 | - public function getMTime() { |
|
62 | - if ($this->fileInfo) { |
|
63 | - return parent::getMTime(); |
|
64 | - } else { |
|
65 | - throw new NotFoundException(); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - public function getSize() { |
|
70 | - if ($this->fileInfo) { |
|
71 | - return parent::getSize(); |
|
72 | - } else { |
|
73 | - throw new NotFoundException(); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - public function getEtag() { |
|
78 | - if ($this->fileInfo) { |
|
79 | - return parent::getEtag(); |
|
80 | - } else { |
|
81 | - throw new NotFoundException(); |
|
82 | - } |
|
83 | - } |
|
84 | - |
|
85 | - public function getPermissions() { |
|
86 | - if ($this->fileInfo) { |
|
87 | - return parent::getPermissions(); |
|
88 | - } else { |
|
89 | - throw new NotFoundException(); |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - public function isReadable() { |
|
94 | - if ($this->fileInfo) { |
|
95 | - return parent::isReadable(); |
|
96 | - } else { |
|
97 | - throw new NotFoundException(); |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - public function isUpdateable() { |
|
102 | - if ($this->fileInfo) { |
|
103 | - return parent::isUpdateable(); |
|
104 | - } else { |
|
105 | - throw new NotFoundException(); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public function isDeletable() { |
|
110 | - if ($this->fileInfo) { |
|
111 | - return parent::isDeletable(); |
|
112 | - } else { |
|
113 | - throw new NotFoundException(); |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - public function isShareable() { |
|
118 | - if ($this->fileInfo) { |
|
119 | - return parent::isShareable(); |
|
120 | - } else { |
|
121 | - throw new NotFoundException(); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - public function getContent() { |
|
126 | - throw new NotFoundException(); |
|
127 | - } |
|
128 | - |
|
129 | - public function putContent($data) { |
|
130 | - throw new NotFoundException(); |
|
131 | - } |
|
132 | - |
|
133 | - public function getMimeType() { |
|
134 | - if ($this->fileInfo) { |
|
135 | - return parent::getMimeType(); |
|
136 | - } else { |
|
137 | - throw new NotFoundException(); |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - public function fopen($mode) { |
|
142 | - throw new NotFoundException(); |
|
143 | - } |
|
29 | + /** |
|
30 | + * @param string $newPath |
|
31 | + * @throws \OCP\Files\NotFoundException |
|
32 | + */ |
|
33 | + public function rename($newPath) { |
|
34 | + throw new NotFoundException(); |
|
35 | + } |
|
36 | + |
|
37 | + public function delete() { |
|
38 | + throw new NotFoundException(); |
|
39 | + } |
|
40 | + |
|
41 | + public function copy($newPath) { |
|
42 | + throw new NotFoundException(); |
|
43 | + } |
|
44 | + |
|
45 | + public function touch($mtime = null) { |
|
46 | + throw new NotFoundException(); |
|
47 | + } |
|
48 | + |
|
49 | + public function getId() { |
|
50 | + if ($this->fileInfo) { |
|
51 | + return parent::getId(); |
|
52 | + } else { |
|
53 | + throw new NotFoundException(); |
|
54 | + } |
|
55 | + } |
|
56 | + |
|
57 | + public function stat() { |
|
58 | + throw new NotFoundException(); |
|
59 | + } |
|
60 | + |
|
61 | + public function getMTime() { |
|
62 | + if ($this->fileInfo) { |
|
63 | + return parent::getMTime(); |
|
64 | + } else { |
|
65 | + throw new NotFoundException(); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + public function getSize() { |
|
70 | + if ($this->fileInfo) { |
|
71 | + return parent::getSize(); |
|
72 | + } else { |
|
73 | + throw new NotFoundException(); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + public function getEtag() { |
|
78 | + if ($this->fileInfo) { |
|
79 | + return parent::getEtag(); |
|
80 | + } else { |
|
81 | + throw new NotFoundException(); |
|
82 | + } |
|
83 | + } |
|
84 | + |
|
85 | + public function getPermissions() { |
|
86 | + if ($this->fileInfo) { |
|
87 | + return parent::getPermissions(); |
|
88 | + } else { |
|
89 | + throw new NotFoundException(); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + public function isReadable() { |
|
94 | + if ($this->fileInfo) { |
|
95 | + return parent::isReadable(); |
|
96 | + } else { |
|
97 | + throw new NotFoundException(); |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + public function isUpdateable() { |
|
102 | + if ($this->fileInfo) { |
|
103 | + return parent::isUpdateable(); |
|
104 | + } else { |
|
105 | + throw new NotFoundException(); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public function isDeletable() { |
|
110 | + if ($this->fileInfo) { |
|
111 | + return parent::isDeletable(); |
|
112 | + } else { |
|
113 | + throw new NotFoundException(); |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + public function isShareable() { |
|
118 | + if ($this->fileInfo) { |
|
119 | + return parent::isShareable(); |
|
120 | + } else { |
|
121 | + throw new NotFoundException(); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + public function getContent() { |
|
126 | + throw new NotFoundException(); |
|
127 | + } |
|
128 | + |
|
129 | + public function putContent($data) { |
|
130 | + throw new NotFoundException(); |
|
131 | + } |
|
132 | + |
|
133 | + public function getMimeType() { |
|
134 | + if ($this->fileInfo) { |
|
135 | + return parent::getMimeType(); |
|
136 | + } else { |
|
137 | + throw new NotFoundException(); |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + public function fopen($mode) { |
|
142 | + throw new NotFoundException(); |
|
143 | + } |
|
144 | 144 | } |
@@ -34,447 +34,447 @@ |
||
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() { |
|
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 | - /** |
|
349 | - * @inheritDoc |
|
350 | - */ |
|
351 | - public function getFullPath($path) { |
|
352 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * @inheritDoc |
|
357 | - */ |
|
358 | - public function getRelativePath($path) { |
|
359 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * @inheritDoc |
|
364 | - */ |
|
365 | - public function isSubNode($node) { |
|
366 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
367 | - } |
|
368 | - |
|
369 | - /** |
|
370 | - * @inheritDoc |
|
371 | - */ |
|
372 | - public function getDirectoryListing() { |
|
373 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * @inheritDoc |
|
378 | - */ |
|
379 | - public function nodeExists($path) { |
|
380 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * @inheritDoc |
|
385 | - */ |
|
386 | - public function newFolder($path) { |
|
387 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * @inheritDoc |
|
392 | - */ |
|
393 | - public function newFile($path) { |
|
394 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * @inheritDoc |
|
399 | - */ |
|
400 | - public function search($query) { |
|
401 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * @inheritDoc |
|
406 | - */ |
|
407 | - public function searchByMime($mimetype) { |
|
408 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * @inheritDoc |
|
413 | - */ |
|
414 | - public function searchByTag($tag, $userId) { |
|
415 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * @inheritDoc |
|
420 | - */ |
|
421 | - public function getById($id) { |
|
422 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * @inheritDoc |
|
427 | - */ |
|
428 | - public function getFreeSpace() { |
|
429 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * @inheritDoc |
|
434 | - */ |
|
435 | - public function isCreatable() { |
|
436 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * @inheritDoc |
|
441 | - */ |
|
442 | - public function getNonExistingName($name) { |
|
443 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
444 | - } |
|
445 | - |
|
446 | - /** |
|
447 | - * @inheritDoc |
|
448 | - */ |
|
449 | - public function move($targetPath) { |
|
450 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * @inheritDoc |
|
455 | - */ |
|
456 | - public function lock($type) { |
|
457 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * @inheritDoc |
|
462 | - */ |
|
463 | - public function changeLock($targetType) { |
|
464 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
465 | - } |
|
466 | - |
|
467 | - /** |
|
468 | - * @inheritDoc |
|
469 | - */ |
|
470 | - public function unlock($type) { |
|
471 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
472 | - } |
|
473 | - |
|
474 | - /** |
|
475 | - * @inheritDoc |
|
476 | - */ |
|
477 | - public function getRecent($limit, $offset = 0) { |
|
478 | - return $this->__call(__FUNCTION__, func_get_args()); |
|
479 | - } |
|
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() { |
|
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 | + /** |
|
349 | + * @inheritDoc |
|
350 | + */ |
|
351 | + public function getFullPath($path) { |
|
352 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * @inheritDoc |
|
357 | + */ |
|
358 | + public function getRelativePath($path) { |
|
359 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * @inheritDoc |
|
364 | + */ |
|
365 | + public function isSubNode($node) { |
|
366 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
367 | + } |
|
368 | + |
|
369 | + /** |
|
370 | + * @inheritDoc |
|
371 | + */ |
|
372 | + public function getDirectoryListing() { |
|
373 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * @inheritDoc |
|
378 | + */ |
|
379 | + public function nodeExists($path) { |
|
380 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * @inheritDoc |
|
385 | + */ |
|
386 | + public function newFolder($path) { |
|
387 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * @inheritDoc |
|
392 | + */ |
|
393 | + public function newFile($path) { |
|
394 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * @inheritDoc |
|
399 | + */ |
|
400 | + public function search($query) { |
|
401 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * @inheritDoc |
|
406 | + */ |
|
407 | + public function searchByMime($mimetype) { |
|
408 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * @inheritDoc |
|
413 | + */ |
|
414 | + public function searchByTag($tag, $userId) { |
|
415 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * @inheritDoc |
|
420 | + */ |
|
421 | + public function getById($id) { |
|
422 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * @inheritDoc |
|
427 | + */ |
|
428 | + public function getFreeSpace() { |
|
429 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * @inheritDoc |
|
434 | + */ |
|
435 | + public function isCreatable() { |
|
436 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * @inheritDoc |
|
441 | + */ |
|
442 | + public function getNonExistingName($name) { |
|
443 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
444 | + } |
|
445 | + |
|
446 | + /** |
|
447 | + * @inheritDoc |
|
448 | + */ |
|
449 | + public function move($targetPath) { |
|
450 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
451 | + } |
|
452 | + |
|
453 | + /** |
|
454 | + * @inheritDoc |
|
455 | + */ |
|
456 | + public function lock($type) { |
|
457 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * @inheritDoc |
|
462 | + */ |
|
463 | + public function changeLock($targetType) { |
|
464 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
465 | + } |
|
466 | + |
|
467 | + /** |
|
468 | + * @inheritDoc |
|
469 | + */ |
|
470 | + public function unlock($type) { |
|
471 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
472 | + } |
|
473 | + |
|
474 | + /** |
|
475 | + * @inheritDoc |
|
476 | + */ |
|
477 | + public function getRecent($limit, $offset = 0) { |
|
478 | + return $this->__call(__FUNCTION__, func_get_args()); |
|
479 | + } |
|
480 | 480 | } |
@@ -30,15 +30,15 @@ |
||
30 | 30 | * Mount provider for regular posix home folders |
31 | 31 | */ |
32 | 32 | class LocalHomeMountProvider implements IHomeMountProvider { |
33 | - /** |
|
34 | - * Get the cache mount for a user |
|
35 | - * |
|
36 | - * @param IUser $user |
|
37 | - * @param IStorageFactory $loader |
|
38 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
39 | - */ |
|
40 | - public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { |
|
41 | - $arguments = ['user' => $user]; |
|
42 | - return new MountPoint('\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader); |
|
43 | - } |
|
33 | + /** |
|
34 | + * Get the cache mount for a user |
|
35 | + * |
|
36 | + * @param IUser $user |
|
37 | + * @param IStorageFactory $loader |
|
38 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
39 | + */ |
|
40 | + public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { |
|
41 | + $arguments = ['user' => $user]; |
|
42 | + return new MountPoint('\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader); |
|
43 | + } |
|
44 | 44 | } |
@@ -27,19 +27,19 @@ |
||
27 | 27 | * Defines the mount point to be (re)moved by the user |
28 | 28 | */ |
29 | 29 | interface MoveableMount { |
30 | - /** |
|
31 | - * Move the mount point to $target |
|
32 | - * |
|
33 | - * @param string $target the target mount point |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function moveMount($target); |
|
30 | + /** |
|
31 | + * Move the mount point to $target |
|
32 | + * |
|
33 | + * @param string $target the target mount point |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function moveMount($target); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Remove the mount points |
|
40 | - * |
|
41 | - * @return mixed |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function removeMount(); |
|
38 | + /** |
|
39 | + * Remove the mount points |
|
40 | + * |
|
41 | + * @return mixed |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function removeMount(); |
|
45 | 45 | } |
@@ -30,137 +30,137 @@ |
||
30 | 30 | use OCP\Files\Mount\IMountPoint; |
31 | 31 | |
32 | 32 | class Manager implements IMountManager { |
33 | - /** |
|
34 | - * @var MountPoint[] |
|
35 | - */ |
|
36 | - private $mounts = array(); |
|
33 | + /** |
|
34 | + * @var MountPoint[] |
|
35 | + */ |
|
36 | + private $mounts = array(); |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IMountPoint $mount |
|
40 | - */ |
|
41 | - public function addMount(IMountPoint $mount) { |
|
42 | - $this->mounts[$mount->getMountPoint()] = $mount; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @param IMountPoint $mount |
|
40 | + */ |
|
41 | + public function addMount(IMountPoint $mount) { |
|
42 | + $this->mounts[$mount->getMountPoint()] = $mount; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $mountPoint |
|
47 | - */ |
|
48 | - public function removeMount($mountPoint) { |
|
49 | - $mountPoint = Filesystem::normalizePath($mountPoint); |
|
50 | - if (strlen($mountPoint) > 1) { |
|
51 | - $mountPoint .= '/'; |
|
52 | - } |
|
53 | - unset($this->mounts[$mountPoint]); |
|
54 | - } |
|
45 | + /** |
|
46 | + * @param string $mountPoint |
|
47 | + */ |
|
48 | + public function removeMount($mountPoint) { |
|
49 | + $mountPoint = Filesystem::normalizePath($mountPoint); |
|
50 | + if (strlen($mountPoint) > 1) { |
|
51 | + $mountPoint .= '/'; |
|
52 | + } |
|
53 | + unset($this->mounts[$mountPoint]); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $mountPoint |
|
58 | - * @param string $target |
|
59 | - */ |
|
60 | - public function moveMount($mountPoint, $target){ |
|
61 | - $this->mounts[$target] = $this->mounts[$mountPoint]; |
|
62 | - unset($this->mounts[$mountPoint]); |
|
63 | - } |
|
56 | + /** |
|
57 | + * @param string $mountPoint |
|
58 | + * @param string $target |
|
59 | + */ |
|
60 | + public function moveMount($mountPoint, $target){ |
|
61 | + $this->mounts[$target] = $this->mounts[$mountPoint]; |
|
62 | + unset($this->mounts[$mountPoint]); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Find the mount for $path |
|
67 | - * |
|
68 | - * @param string $path |
|
69 | - * @return MountPoint |
|
70 | - */ |
|
71 | - public function find($path) { |
|
72 | - \OC_Util::setupFS(); |
|
73 | - $path = $this->formatPath($path); |
|
74 | - if (isset($this->mounts[$path])) { |
|
75 | - return $this->mounts[$path]; |
|
76 | - } |
|
65 | + /** |
|
66 | + * Find the mount for $path |
|
67 | + * |
|
68 | + * @param string $path |
|
69 | + * @return MountPoint |
|
70 | + */ |
|
71 | + public function find($path) { |
|
72 | + \OC_Util::setupFS(); |
|
73 | + $path = $this->formatPath($path); |
|
74 | + if (isset($this->mounts[$path])) { |
|
75 | + return $this->mounts[$path]; |
|
76 | + } |
|
77 | 77 | |
78 | - \OC_Hook::emit('OC_Filesystem', 'get_mountpoint', array('path' => $path)); |
|
79 | - $foundMountPoint = ''; |
|
80 | - $mountPoints = array_keys($this->mounts); |
|
81 | - foreach ($mountPoints as $mountpoint) { |
|
82 | - if (strpos($path, $mountpoint) === 0 and strlen($mountpoint) > strlen($foundMountPoint)) { |
|
83 | - $foundMountPoint = $mountpoint; |
|
84 | - } |
|
85 | - } |
|
86 | - if (isset($this->mounts[$foundMountPoint])) { |
|
87 | - return $this->mounts[$foundMountPoint]; |
|
88 | - } else { |
|
89 | - return null; |
|
90 | - } |
|
91 | - } |
|
78 | + \OC_Hook::emit('OC_Filesystem', 'get_mountpoint', array('path' => $path)); |
|
79 | + $foundMountPoint = ''; |
|
80 | + $mountPoints = array_keys($this->mounts); |
|
81 | + foreach ($mountPoints as $mountpoint) { |
|
82 | + if (strpos($path, $mountpoint) === 0 and strlen($mountpoint) > strlen($foundMountPoint)) { |
|
83 | + $foundMountPoint = $mountpoint; |
|
84 | + } |
|
85 | + } |
|
86 | + if (isset($this->mounts[$foundMountPoint])) { |
|
87 | + return $this->mounts[$foundMountPoint]; |
|
88 | + } else { |
|
89 | + return null; |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Find all mounts in $path |
|
95 | - * |
|
96 | - * @param string $path |
|
97 | - * @return MountPoint[] |
|
98 | - */ |
|
99 | - public function findIn($path) { |
|
100 | - \OC_Util::setupFS(); |
|
101 | - $path = $this->formatPath($path); |
|
102 | - $result = array(); |
|
103 | - $pathLength = strlen($path); |
|
104 | - $mountPoints = array_keys($this->mounts); |
|
105 | - foreach ($mountPoints as $mountPoint) { |
|
106 | - if (substr($mountPoint, 0, $pathLength) === $path and strlen($mountPoint) > $pathLength) { |
|
107 | - $result[] = $this->mounts[$mountPoint]; |
|
108 | - } |
|
109 | - } |
|
110 | - return $result; |
|
111 | - } |
|
93 | + /** |
|
94 | + * Find all mounts in $path |
|
95 | + * |
|
96 | + * @param string $path |
|
97 | + * @return MountPoint[] |
|
98 | + */ |
|
99 | + public function findIn($path) { |
|
100 | + \OC_Util::setupFS(); |
|
101 | + $path = $this->formatPath($path); |
|
102 | + $result = array(); |
|
103 | + $pathLength = strlen($path); |
|
104 | + $mountPoints = array_keys($this->mounts); |
|
105 | + foreach ($mountPoints as $mountPoint) { |
|
106 | + if (substr($mountPoint, 0, $pathLength) === $path and strlen($mountPoint) > $pathLength) { |
|
107 | + $result[] = $this->mounts[$mountPoint]; |
|
108 | + } |
|
109 | + } |
|
110 | + return $result; |
|
111 | + } |
|
112 | 112 | |
113 | - public function clear() { |
|
114 | - $this->mounts = array(); |
|
115 | - } |
|
113 | + public function clear() { |
|
114 | + $this->mounts = array(); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Find mounts by storage id |
|
119 | - * |
|
120 | - * @param string $id |
|
121 | - * @return MountPoint[] |
|
122 | - */ |
|
123 | - public function findByStorageId($id) { |
|
124 | - \OC_Util::setupFS(); |
|
125 | - if (strlen($id) > 64) { |
|
126 | - $id = md5($id); |
|
127 | - } |
|
128 | - $result = array(); |
|
129 | - foreach ($this->mounts as $mount) { |
|
130 | - if ($mount->getStorageId() === $id) { |
|
131 | - $result[] = $mount; |
|
132 | - } |
|
133 | - } |
|
134 | - return $result; |
|
135 | - } |
|
117 | + /** |
|
118 | + * Find mounts by storage id |
|
119 | + * |
|
120 | + * @param string $id |
|
121 | + * @return MountPoint[] |
|
122 | + */ |
|
123 | + public function findByStorageId($id) { |
|
124 | + \OC_Util::setupFS(); |
|
125 | + if (strlen($id) > 64) { |
|
126 | + $id = md5($id); |
|
127 | + } |
|
128 | + $result = array(); |
|
129 | + foreach ($this->mounts as $mount) { |
|
130 | + if ($mount->getStorageId() === $id) { |
|
131 | + $result[] = $mount; |
|
132 | + } |
|
133 | + } |
|
134 | + return $result; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return MountPoint[] |
|
139 | - */ |
|
140 | - public function getAll() { |
|
141 | - return $this->mounts; |
|
142 | - } |
|
137 | + /** |
|
138 | + * @return MountPoint[] |
|
139 | + */ |
|
140 | + public function getAll() { |
|
141 | + return $this->mounts; |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * Find mounts by numeric storage id |
|
146 | - * |
|
147 | - * @param int $id |
|
148 | - * @return MountPoint[] |
|
149 | - */ |
|
150 | - public function findByNumericId($id) { |
|
151 | - $storageId = \OC\Files\Cache\Storage::getStorageId($id); |
|
152 | - return $this->findByStorageId($storageId); |
|
153 | - } |
|
144 | + /** |
|
145 | + * Find mounts by numeric storage id |
|
146 | + * |
|
147 | + * @param int $id |
|
148 | + * @return MountPoint[] |
|
149 | + */ |
|
150 | + public function findByNumericId($id) { |
|
151 | + $storageId = \OC\Files\Cache\Storage::getStorageId($id); |
|
152 | + return $this->findByStorageId($storageId); |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * @param string $path |
|
157 | - * @return string |
|
158 | - */ |
|
159 | - private function formatPath($path) { |
|
160 | - $path = Filesystem::normalizePath($path); |
|
161 | - if (strlen($path) > 1) { |
|
162 | - $path .= '/'; |
|
163 | - } |
|
164 | - return $path; |
|
165 | - } |
|
155 | + /** |
|
156 | + * @param string $path |
|
157 | + * @return string |
|
158 | + */ |
|
159 | + private function formatPath($path) { |
|
160 | + $path = Filesystem::normalizePath($path); |
|
161 | + if (strlen($path) > 1) { |
|
162 | + $path .= '/'; |
|
163 | + } |
|
164 | + return $path; |
|
165 | + } |
|
166 | 166 | } |
@@ -27,24 +27,24 @@ |
||
27 | 27 | |
28 | 28 | class Factory { |
29 | 29 | |
30 | - /** @var IRootFolder */ |
|
31 | - private $rootFolder; |
|
30 | + /** @var IRootFolder */ |
|
31 | + private $rootFolder; |
|
32 | 32 | |
33 | - /** @var SystemConfig */ |
|
34 | - private $config; |
|
33 | + /** @var SystemConfig */ |
|
34 | + private $config; |
|
35 | 35 | |
36 | - public function __construct(IRootFolder $rootFolder, |
|
37 | - SystemConfig $systemConfig) { |
|
36 | + public function __construct(IRootFolder $rootFolder, |
|
37 | + SystemConfig $systemConfig) { |
|
38 | 38 | |
39 | - $this->rootFolder = $rootFolder; |
|
40 | - $this->config = $systemConfig; |
|
41 | - } |
|
39 | + $this->rootFolder = $rootFolder; |
|
40 | + $this->config = $systemConfig; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $appId |
|
45 | - * @return AppData |
|
46 | - */ |
|
47 | - public function get($appId) { |
|
48 | - return new AppData($this->rootFolder, $this->config, $appId); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @param string $appId |
|
45 | + * @return AppData |
|
46 | + */ |
|
47 | + public function get($appId) { |
|
48 | + return new AppData($this->rootFolder, $this->config, $appId); |
|
49 | + } |
|
50 | 50 | } |
@@ -34,98 +34,98 @@ |
||
34 | 34 | |
35 | 35 | class AppData implements IAppData { |
36 | 36 | |
37 | - /** @var IRootFolder */ |
|
38 | - private $rootFolder; |
|
39 | - |
|
40 | - /** @var SystemConfig */ |
|
41 | - private $config; |
|
42 | - |
|
43 | - /** @var string */ |
|
44 | - private $appId; |
|
45 | - |
|
46 | - /** @var Folder */ |
|
47 | - private $folder; |
|
48 | - |
|
49 | - /** |
|
50 | - * AppData constructor. |
|
51 | - * |
|
52 | - * @param IRootFolder $rootFolder |
|
53 | - * @param SystemConfig $systemConfig |
|
54 | - * @param string $appId |
|
55 | - */ |
|
56 | - public function __construct(IRootFolder $rootFolder, |
|
57 | - SystemConfig $systemConfig, |
|
58 | - $appId) { |
|
59 | - |
|
60 | - $this->rootFolder = $rootFolder; |
|
61 | - $this->config = $systemConfig; |
|
62 | - $this->appId = $appId; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @return Folder |
|
67 | - * @throws \RuntimeException |
|
68 | - */ |
|
69 | - private function getAppDataFolder() { |
|
70 | - if ($this->folder === null) { |
|
71 | - $instanceId = $this->config->getValue('instanceid', null); |
|
72 | - if ($instanceId === null) { |
|
73 | - throw new \RuntimeException('no instance id!'); |
|
74 | - } |
|
75 | - |
|
76 | - $name = 'appdata_' . $instanceId; |
|
77 | - |
|
78 | - try { |
|
79 | - $appDataFolder = $this->rootFolder->get($name); |
|
80 | - } catch (NotFoundException $e) { |
|
81 | - try { |
|
82 | - $appDataFolder = $this->rootFolder->newFolder($name); |
|
83 | - } catch (NotPermittedException $e) { |
|
84 | - throw new \RuntimeException('Could not get appdata folder'); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - try { |
|
89 | - $appDataFolder = $appDataFolder->get($this->appId); |
|
90 | - } catch (NotFoundException $e) { |
|
91 | - try { |
|
92 | - $appDataFolder = $appDataFolder->newFolder($this->appId); |
|
93 | - } catch (NotPermittedException $e) { |
|
94 | - throw new \RuntimeException('Could not get appdata folder for ' . $this->appId); |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - $this->folder = $appDataFolder; |
|
99 | - } |
|
100 | - |
|
101 | - return $this->folder; |
|
102 | - } |
|
103 | - |
|
104 | - public function getFolder($name) { |
|
105 | - $node = $this->getAppDataFolder()->get($name); |
|
106 | - |
|
107 | - /** @var Folder $node */ |
|
108 | - return new SimpleFolder($node); |
|
109 | - } |
|
110 | - |
|
111 | - public function newFolder($name) { |
|
112 | - $folder = $this->getAppDataFolder()->newFolder($name); |
|
113 | - |
|
114 | - return new SimpleFolder($folder); |
|
115 | - } |
|
116 | - |
|
117 | - public function getDirectoryListing() { |
|
118 | - $listing = $this->getAppDataFolder()->getDirectoryListing(); |
|
119 | - |
|
120 | - $fileListing = array_map(function(Node $folder) { |
|
121 | - if ($folder instanceof Folder) { |
|
122 | - return new SimpleFolder($folder); |
|
123 | - } |
|
124 | - return null; |
|
125 | - }, $listing); |
|
126 | - |
|
127 | - $fileListing = array_filter($fileListing); |
|
128 | - |
|
129 | - return array_values($fileListing); |
|
130 | - } |
|
37 | + /** @var IRootFolder */ |
|
38 | + private $rootFolder; |
|
39 | + |
|
40 | + /** @var SystemConfig */ |
|
41 | + private $config; |
|
42 | + |
|
43 | + /** @var string */ |
|
44 | + private $appId; |
|
45 | + |
|
46 | + /** @var Folder */ |
|
47 | + private $folder; |
|
48 | + |
|
49 | + /** |
|
50 | + * AppData constructor. |
|
51 | + * |
|
52 | + * @param IRootFolder $rootFolder |
|
53 | + * @param SystemConfig $systemConfig |
|
54 | + * @param string $appId |
|
55 | + */ |
|
56 | + public function __construct(IRootFolder $rootFolder, |
|
57 | + SystemConfig $systemConfig, |
|
58 | + $appId) { |
|
59 | + |
|
60 | + $this->rootFolder = $rootFolder; |
|
61 | + $this->config = $systemConfig; |
|
62 | + $this->appId = $appId; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @return Folder |
|
67 | + * @throws \RuntimeException |
|
68 | + */ |
|
69 | + private function getAppDataFolder() { |
|
70 | + if ($this->folder === null) { |
|
71 | + $instanceId = $this->config->getValue('instanceid', null); |
|
72 | + if ($instanceId === null) { |
|
73 | + throw new \RuntimeException('no instance id!'); |
|
74 | + } |
|
75 | + |
|
76 | + $name = 'appdata_' . $instanceId; |
|
77 | + |
|
78 | + try { |
|
79 | + $appDataFolder = $this->rootFolder->get($name); |
|
80 | + } catch (NotFoundException $e) { |
|
81 | + try { |
|
82 | + $appDataFolder = $this->rootFolder->newFolder($name); |
|
83 | + } catch (NotPermittedException $e) { |
|
84 | + throw new \RuntimeException('Could not get appdata folder'); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + try { |
|
89 | + $appDataFolder = $appDataFolder->get($this->appId); |
|
90 | + } catch (NotFoundException $e) { |
|
91 | + try { |
|
92 | + $appDataFolder = $appDataFolder->newFolder($this->appId); |
|
93 | + } catch (NotPermittedException $e) { |
|
94 | + throw new \RuntimeException('Could not get appdata folder for ' . $this->appId); |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + $this->folder = $appDataFolder; |
|
99 | + } |
|
100 | + |
|
101 | + return $this->folder; |
|
102 | + } |
|
103 | + |
|
104 | + public function getFolder($name) { |
|
105 | + $node = $this->getAppDataFolder()->get($name); |
|
106 | + |
|
107 | + /** @var Folder $node */ |
|
108 | + return new SimpleFolder($node); |
|
109 | + } |
|
110 | + |
|
111 | + public function newFolder($name) { |
|
112 | + $folder = $this->getAppDataFolder()->newFolder($name); |
|
113 | + |
|
114 | + return new SimpleFolder($folder); |
|
115 | + } |
|
116 | + |
|
117 | + public function getDirectoryListing() { |
|
118 | + $listing = $this->getAppDataFolder()->getDirectoryListing(); |
|
119 | + |
|
120 | + $fileListing = array_map(function(Node $folder) { |
|
121 | + if ($folder instanceof Folder) { |
|
122 | + return new SimpleFolder($folder); |
|
123 | + } |
|
124 | + return null; |
|
125 | + }, $listing); |
|
126 | + |
|
127 | + $fileListing = array_filter($fileListing); |
|
128 | + |
|
129 | + return array_values($fileListing); |
|
130 | + } |
|
131 | 131 | } |