@@ -19,49 +19,49 @@ |
||
19 | 19 | use Test\TestCase; |
20 | 20 | |
21 | 21 | class TrashbinPluginTest extends TestCase { |
22 | - private Server $server; |
|
22 | + private Server $server; |
|
23 | 23 | |
24 | - protected function setUp(): void { |
|
25 | - parent::setUp(); |
|
24 | + protected function setUp(): void { |
|
25 | + parent::setUp(); |
|
26 | 26 | |
27 | - $tree = $this->createMock(Tree::class); |
|
28 | - $this->server = new Server($tree); |
|
29 | - } |
|
27 | + $tree = $this->createMock(Tree::class); |
|
28 | + $this->server = new Server($tree); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @dataProvider quotaProvider |
|
33 | - */ |
|
34 | - public function testQuota(int $quota, int $fileSize, bool $expectedResult): void { |
|
35 | - $fileInfo = $this->createMock(ITrashItem::class); |
|
36 | - $fileInfo->method('getSize')->willReturn($fileSize); |
|
31 | + /** |
|
32 | + * @dataProvider quotaProvider |
|
33 | + */ |
|
34 | + public function testQuota(int $quota, int $fileSize, bool $expectedResult): void { |
|
35 | + $fileInfo = $this->createMock(ITrashItem::class); |
|
36 | + $fileInfo->method('getSize')->willReturn($fileSize); |
|
37 | 37 | |
38 | - $trashNode = $this->createMock(ITrash::class); |
|
39 | - $trashNode->method('getFileInfo')->willReturn($fileInfo); |
|
38 | + $trashNode = $this->createMock(ITrash::class); |
|
39 | + $trashNode->method('getFileInfo')->willReturn($fileInfo); |
|
40 | 40 | |
41 | - $restoreNode = $this->createMock(RestoreFolder::class); |
|
41 | + $restoreNode = $this->createMock(RestoreFolder::class); |
|
42 | 42 | |
43 | - $this->server->tree->method('getNodeForPath')->willReturn($trashNode, $restoreNode); |
|
43 | + $this->server->tree->method('getNodeForPath')->willReturn($trashNode, $restoreNode); |
|
44 | 44 | |
45 | - $previewManager = $this->createMock(IPreview::class); |
|
45 | + $previewManager = $this->createMock(IPreview::class); |
|
46 | 46 | |
47 | - $view = $this->createMock(View::class); |
|
48 | - $view->method('free_space')->willReturn($quota); |
|
47 | + $view = $this->createMock(View::class); |
|
48 | + $view->method('free_space')->willReturn($quota); |
|
49 | 49 | |
50 | - $plugin = new TrashbinPlugin($previewManager, $view); |
|
51 | - $plugin->initialize($this->server); |
|
50 | + $plugin = new TrashbinPlugin($previewManager, $view); |
|
51 | + $plugin->initialize($this->server); |
|
52 | 52 | |
53 | - $sourcePath = 'trashbin/test/trash/file1'; |
|
54 | - $destinationPath = 'trashbin/test/restore/file1'; |
|
55 | - $this->assertEquals($expectedResult, $plugin->beforeMove($sourcePath, $destinationPath)); |
|
56 | - } |
|
53 | + $sourcePath = 'trashbin/test/trash/file1'; |
|
54 | + $destinationPath = 'trashbin/test/restore/file1'; |
|
55 | + $this->assertEquals($expectedResult, $plugin->beforeMove($sourcePath, $destinationPath)); |
|
56 | + } |
|
57 | 57 | |
58 | - public function quotaProvider(): array { |
|
59 | - return [ |
|
60 | - [ 1024, 512, true ], |
|
61 | - [ 512, 513, false ], |
|
62 | - [ FileInfo::SPACE_NOT_COMPUTED, 1024, true ], |
|
63 | - [ FileInfo::SPACE_UNKNOWN, 1024, true ], |
|
64 | - [ FileInfo::SPACE_UNLIMITED, 1024, true ] |
|
65 | - ]; |
|
66 | - } |
|
58 | + public function quotaProvider(): array { |
|
59 | + return [ |
|
60 | + [ 1024, 512, true ], |
|
61 | + [ 512, 513, false ], |
|
62 | + [ FileInfo::SPACE_NOT_COMPUTED, 1024, true ], |
|
63 | + [ FileInfo::SPACE_UNKNOWN, 1024, true ], |
|
64 | + [ FileInfo::SPACE_UNLIMITED, 1024, true ] |
|
65 | + ]; |
|
66 | + } |
|
67 | 67 | } |
@@ -57,11 +57,11 @@ |
||
57 | 57 | |
58 | 58 | public function quotaProvider(): array { |
59 | 59 | return [ |
60 | - [ 1024, 512, true ], |
|
61 | - [ 512, 513, false ], |
|
62 | - [ FileInfo::SPACE_NOT_COMPUTED, 1024, true ], |
|
63 | - [ FileInfo::SPACE_UNKNOWN, 1024, true ], |
|
64 | - [ FileInfo::SPACE_UNLIMITED, 1024, true ] |
|
60 | + [1024, 512, true], |
|
61 | + [512, 513, false], |
|
62 | + [FileInfo::SPACE_NOT_COMPUTED, 1024, true], |
|
63 | + [FileInfo::SPACE_UNKNOWN, 1024, true], |
|
64 | + [FileInfo::SPACE_UNLIMITED, 1024, true] |
|
65 | 65 | ]; |
66 | 66 | } |
67 | 67 | } |
@@ -22,159 +22,159 @@ |
||
22 | 22 | use Sabre\HTTP\ResponseInterface; |
23 | 23 | |
24 | 24 | class TrashbinPlugin extends ServerPlugin { |
25 | - public const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename'; |
|
26 | - public const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location'; |
|
27 | - public const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time'; |
|
28 | - public const TRASHBIN_TITLE = '{http://nextcloud.org/ns}trashbin-title'; |
|
29 | - public const TRASHBIN_DELETED_BY_ID = '{http://nextcloud.org/ns}trashbin-deleted-by-id'; |
|
30 | - public const TRASHBIN_DELETED_BY_DISPLAY_NAME = '{http://nextcloud.org/ns}trashbin-deleted-by-display-name'; |
|
31 | - public const TRASHBIN_BACKEND = '{http://nextcloud.org/ns}trashbin-backend'; |
|
32 | - |
|
33 | - /** @var Server */ |
|
34 | - private $server; |
|
35 | - |
|
36 | - public function __construct( |
|
37 | - private IPreview $previewManager, |
|
38 | - private View $view, |
|
39 | - ) { |
|
40 | - } |
|
41 | - |
|
42 | - public function initialize(Server $server) { |
|
43 | - $this->server = $server; |
|
44 | - |
|
45 | - $this->server->on('propFind', [$this, 'propFind']); |
|
46 | - $this->server->on('afterMethod:GET', [$this,'httpGet']); |
|
47 | - $this->server->on('beforeMove', [$this, 'beforeMove']); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - public function propFind(PropFind $propFind, INode $node) { |
|
52 | - if (!($node instanceof ITrash)) { |
|
53 | - return; |
|
54 | - } |
|
55 | - |
|
56 | - $propFind->handle(self::TRASHBIN_FILENAME, function () use ($node) { |
|
57 | - return $node->getFilename(); |
|
58 | - }); |
|
59 | - |
|
60 | - $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function () use ($node) { |
|
61 | - return $node->getOriginalLocation(); |
|
62 | - }); |
|
63 | - |
|
64 | - $propFind->handle(self::TRASHBIN_TITLE, function () use ($node) { |
|
65 | - return $node->getTitle(); |
|
66 | - }); |
|
67 | - |
|
68 | - $propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) { |
|
69 | - return $node->getDeletionTime(); |
|
70 | - }); |
|
71 | - |
|
72 | - $propFind->handle(self::TRASHBIN_DELETED_BY_ID, function () use ($node) { |
|
73 | - return $node->getDeletedBy()?->getUID(); |
|
74 | - }); |
|
75 | - |
|
76 | - $propFind->handle(self::TRASHBIN_DELETED_BY_DISPLAY_NAME, function () use ($node) { |
|
77 | - return $node->getDeletedBy()?->getDisplayName(); |
|
78 | - }); |
|
79 | - |
|
80 | - // Pass the real filename as the DAV display name |
|
81 | - $propFind->handle(FilesPlugin::DISPLAYNAME_PROPERTYNAME, function () use ($node) { |
|
82 | - return $node->getFilename(); |
|
83 | - }); |
|
84 | - |
|
85 | - $propFind->handle(FilesPlugin::SIZE_PROPERTYNAME, function () use ($node) { |
|
86 | - return $node->getSize(); |
|
87 | - }); |
|
88 | - |
|
89 | - $propFind->handle(FilesPlugin::FILEID_PROPERTYNAME, function () use ($node) { |
|
90 | - return $node->getFileId(); |
|
91 | - }); |
|
92 | - |
|
93 | - $propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, function () { |
|
94 | - return 'GD'; // read + delete |
|
95 | - }); |
|
96 | - |
|
97 | - $propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, function () use ($node) { |
|
98 | - // add fake etag, it is only needed to identify the preview image |
|
99 | - return $node->getLastModified(); |
|
100 | - }); |
|
101 | - |
|
102 | - $propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, function () use ($node) { |
|
103 | - // add fake etag, it is only needed to identify the preview image |
|
104 | - return $node->getFileId(); |
|
105 | - }); |
|
106 | - |
|
107 | - $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { |
|
108 | - return $this->previewManager->isAvailable($node->getFileInfo()); |
|
109 | - }); |
|
110 | - |
|
111 | - $propFind->handle(FilesPlugin::MOUNT_TYPE_PROPERTYNAME, function () { |
|
112 | - return ''; |
|
113 | - }); |
|
114 | - |
|
115 | - $propFind->handle(self::TRASHBIN_BACKEND, function () use ($node) { |
|
116 | - $fileInfo = $node->getFileInfo(); |
|
117 | - if (!($fileInfo instanceof ITrashItem)) { |
|
118 | - return ''; |
|
119 | - } |
|
120 | - return $fileInfo->getTrashBackend()::class; |
|
121 | - }); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Set real filename on trashbin download |
|
126 | - * |
|
127 | - * @param RequestInterface $request |
|
128 | - * @param ResponseInterface $response |
|
129 | - */ |
|
130 | - public function httpGet(RequestInterface $request, ResponseInterface $response): void { |
|
131 | - $path = $request->getPath(); |
|
132 | - $node = $this->server->tree->getNodeForPath($path); |
|
133 | - if ($node instanceof ITrash) { |
|
134 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . $node->getFilename() . '"'); |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Check if a user has available space before attempting to |
|
140 | - * restore from trashbin unless they have unlimited quota. |
|
141 | - * |
|
142 | - * @param string $sourcePath |
|
143 | - * @param string $destinationPath |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function beforeMove(string $sourcePath, string $destinationPath): bool { |
|
147 | - try { |
|
148 | - $node = $this->server->tree->getNodeForPath($sourcePath); |
|
149 | - $destinationNodeParent = $this->server->tree->getNodeForPath(dirname($destinationPath)); |
|
150 | - } catch (\Sabre\DAV\Exception $e) { |
|
151 | - \OCP\Server::get(LoggerInterface::class) |
|
152 | - ->error($e->getMessage(), ['app' => 'files_trashbin', 'exception' => $e]); |
|
153 | - return true; |
|
154 | - } |
|
155 | - |
|
156 | - // Check if a file is being restored before proceeding |
|
157 | - if (!$node instanceof ITrash || !$destinationNodeParent instanceof RestoreFolder) { |
|
158 | - return true; |
|
159 | - } |
|
160 | - |
|
161 | - $fileInfo = $node->getFileInfo(); |
|
162 | - if (!$fileInfo instanceof ITrashItem) { |
|
163 | - return true; |
|
164 | - } |
|
165 | - $restoreFolder = dirname($fileInfo->getOriginalLocation()); |
|
166 | - $freeSpace = $this->view->free_space($restoreFolder); |
|
167 | - if ($freeSpace === FileInfo::SPACE_NOT_COMPUTED || |
|
168 | - $freeSpace === FileInfo::SPACE_UNKNOWN || |
|
169 | - $freeSpace === FileInfo::SPACE_UNLIMITED) { |
|
170 | - return true; |
|
171 | - } |
|
172 | - $filesize = $fileInfo->getSize(); |
|
173 | - if ($freeSpace < $filesize) { |
|
174 | - $this->server->httpResponse->setStatus(507); |
|
175 | - return false; |
|
176 | - } |
|
177 | - |
|
178 | - return true; |
|
179 | - } |
|
25 | + public const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename'; |
|
26 | + public const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location'; |
|
27 | + public const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time'; |
|
28 | + public const TRASHBIN_TITLE = '{http://nextcloud.org/ns}trashbin-title'; |
|
29 | + public const TRASHBIN_DELETED_BY_ID = '{http://nextcloud.org/ns}trashbin-deleted-by-id'; |
|
30 | + public const TRASHBIN_DELETED_BY_DISPLAY_NAME = '{http://nextcloud.org/ns}trashbin-deleted-by-display-name'; |
|
31 | + public const TRASHBIN_BACKEND = '{http://nextcloud.org/ns}trashbin-backend'; |
|
32 | + |
|
33 | + /** @var Server */ |
|
34 | + private $server; |
|
35 | + |
|
36 | + public function __construct( |
|
37 | + private IPreview $previewManager, |
|
38 | + private View $view, |
|
39 | + ) { |
|
40 | + } |
|
41 | + |
|
42 | + public function initialize(Server $server) { |
|
43 | + $this->server = $server; |
|
44 | + |
|
45 | + $this->server->on('propFind', [$this, 'propFind']); |
|
46 | + $this->server->on('afterMethod:GET', [$this,'httpGet']); |
|
47 | + $this->server->on('beforeMove', [$this, 'beforeMove']); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + public function propFind(PropFind $propFind, INode $node) { |
|
52 | + if (!($node instanceof ITrash)) { |
|
53 | + return; |
|
54 | + } |
|
55 | + |
|
56 | + $propFind->handle(self::TRASHBIN_FILENAME, function () use ($node) { |
|
57 | + return $node->getFilename(); |
|
58 | + }); |
|
59 | + |
|
60 | + $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function () use ($node) { |
|
61 | + return $node->getOriginalLocation(); |
|
62 | + }); |
|
63 | + |
|
64 | + $propFind->handle(self::TRASHBIN_TITLE, function () use ($node) { |
|
65 | + return $node->getTitle(); |
|
66 | + }); |
|
67 | + |
|
68 | + $propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) { |
|
69 | + return $node->getDeletionTime(); |
|
70 | + }); |
|
71 | + |
|
72 | + $propFind->handle(self::TRASHBIN_DELETED_BY_ID, function () use ($node) { |
|
73 | + return $node->getDeletedBy()?->getUID(); |
|
74 | + }); |
|
75 | + |
|
76 | + $propFind->handle(self::TRASHBIN_DELETED_BY_DISPLAY_NAME, function () use ($node) { |
|
77 | + return $node->getDeletedBy()?->getDisplayName(); |
|
78 | + }); |
|
79 | + |
|
80 | + // Pass the real filename as the DAV display name |
|
81 | + $propFind->handle(FilesPlugin::DISPLAYNAME_PROPERTYNAME, function () use ($node) { |
|
82 | + return $node->getFilename(); |
|
83 | + }); |
|
84 | + |
|
85 | + $propFind->handle(FilesPlugin::SIZE_PROPERTYNAME, function () use ($node) { |
|
86 | + return $node->getSize(); |
|
87 | + }); |
|
88 | + |
|
89 | + $propFind->handle(FilesPlugin::FILEID_PROPERTYNAME, function () use ($node) { |
|
90 | + return $node->getFileId(); |
|
91 | + }); |
|
92 | + |
|
93 | + $propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, function () { |
|
94 | + return 'GD'; // read + delete |
|
95 | + }); |
|
96 | + |
|
97 | + $propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, function () use ($node) { |
|
98 | + // add fake etag, it is only needed to identify the preview image |
|
99 | + return $node->getLastModified(); |
|
100 | + }); |
|
101 | + |
|
102 | + $propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, function () use ($node) { |
|
103 | + // add fake etag, it is only needed to identify the preview image |
|
104 | + return $node->getFileId(); |
|
105 | + }); |
|
106 | + |
|
107 | + $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { |
|
108 | + return $this->previewManager->isAvailable($node->getFileInfo()); |
|
109 | + }); |
|
110 | + |
|
111 | + $propFind->handle(FilesPlugin::MOUNT_TYPE_PROPERTYNAME, function () { |
|
112 | + return ''; |
|
113 | + }); |
|
114 | + |
|
115 | + $propFind->handle(self::TRASHBIN_BACKEND, function () use ($node) { |
|
116 | + $fileInfo = $node->getFileInfo(); |
|
117 | + if (!($fileInfo instanceof ITrashItem)) { |
|
118 | + return ''; |
|
119 | + } |
|
120 | + return $fileInfo->getTrashBackend()::class; |
|
121 | + }); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Set real filename on trashbin download |
|
126 | + * |
|
127 | + * @param RequestInterface $request |
|
128 | + * @param ResponseInterface $response |
|
129 | + */ |
|
130 | + public function httpGet(RequestInterface $request, ResponseInterface $response): void { |
|
131 | + $path = $request->getPath(); |
|
132 | + $node = $this->server->tree->getNodeForPath($path); |
|
133 | + if ($node instanceof ITrash) { |
|
134 | + $response->addHeader('Content-Disposition', 'attachment; filename="' . $node->getFilename() . '"'); |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Check if a user has available space before attempting to |
|
140 | + * restore from trashbin unless they have unlimited quota. |
|
141 | + * |
|
142 | + * @param string $sourcePath |
|
143 | + * @param string $destinationPath |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function beforeMove(string $sourcePath, string $destinationPath): bool { |
|
147 | + try { |
|
148 | + $node = $this->server->tree->getNodeForPath($sourcePath); |
|
149 | + $destinationNodeParent = $this->server->tree->getNodeForPath(dirname($destinationPath)); |
|
150 | + } catch (\Sabre\DAV\Exception $e) { |
|
151 | + \OCP\Server::get(LoggerInterface::class) |
|
152 | + ->error($e->getMessage(), ['app' => 'files_trashbin', 'exception' => $e]); |
|
153 | + return true; |
|
154 | + } |
|
155 | + |
|
156 | + // Check if a file is being restored before proceeding |
|
157 | + if (!$node instanceof ITrash || !$destinationNodeParent instanceof RestoreFolder) { |
|
158 | + return true; |
|
159 | + } |
|
160 | + |
|
161 | + $fileInfo = $node->getFileInfo(); |
|
162 | + if (!$fileInfo instanceof ITrashItem) { |
|
163 | + return true; |
|
164 | + } |
|
165 | + $restoreFolder = dirname($fileInfo->getOriginalLocation()); |
|
166 | + $freeSpace = $this->view->free_space($restoreFolder); |
|
167 | + if ($freeSpace === FileInfo::SPACE_NOT_COMPUTED || |
|
168 | + $freeSpace === FileInfo::SPACE_UNKNOWN || |
|
169 | + $freeSpace === FileInfo::SPACE_UNLIMITED) { |
|
170 | + return true; |
|
171 | + } |
|
172 | + $filesize = $fileInfo->getSize(); |
|
173 | + if ($freeSpace < $filesize) { |
|
174 | + $this->server->httpResponse->setStatus(507); |
|
175 | + return false; |
|
176 | + } |
|
177 | + |
|
178 | + return true; |
|
179 | + } |
|
180 | 180 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->server = $server; |
44 | 44 | |
45 | 45 | $this->server->on('propFind', [$this, 'propFind']); |
46 | - $this->server->on('afterMethod:GET', [$this,'httpGet']); |
|
46 | + $this->server->on('afterMethod:GET', [$this, 'httpGet']); |
|
47 | 47 | $this->server->on('beforeMove', [$this, 'beforeMove']); |
48 | 48 | } |
49 | 49 | |
@@ -53,66 +53,66 @@ discard block |
||
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - $propFind->handle(self::TRASHBIN_FILENAME, function () use ($node) { |
|
56 | + $propFind->handle(self::TRASHBIN_FILENAME, function() use ($node) { |
|
57 | 57 | return $node->getFilename(); |
58 | 58 | }); |
59 | 59 | |
60 | - $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function () use ($node) { |
|
60 | + $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function() use ($node) { |
|
61 | 61 | return $node->getOriginalLocation(); |
62 | 62 | }); |
63 | 63 | |
64 | - $propFind->handle(self::TRASHBIN_TITLE, function () use ($node) { |
|
64 | + $propFind->handle(self::TRASHBIN_TITLE, function() use ($node) { |
|
65 | 65 | return $node->getTitle(); |
66 | 66 | }); |
67 | 67 | |
68 | - $propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) { |
|
68 | + $propFind->handle(self::TRASHBIN_DELETION_TIME, function() use ($node) { |
|
69 | 69 | return $node->getDeletionTime(); |
70 | 70 | }); |
71 | 71 | |
72 | - $propFind->handle(self::TRASHBIN_DELETED_BY_ID, function () use ($node) { |
|
72 | + $propFind->handle(self::TRASHBIN_DELETED_BY_ID, function() use ($node) { |
|
73 | 73 | return $node->getDeletedBy()?->getUID(); |
74 | 74 | }); |
75 | 75 | |
76 | - $propFind->handle(self::TRASHBIN_DELETED_BY_DISPLAY_NAME, function () use ($node) { |
|
76 | + $propFind->handle(self::TRASHBIN_DELETED_BY_DISPLAY_NAME, function() use ($node) { |
|
77 | 77 | return $node->getDeletedBy()?->getDisplayName(); |
78 | 78 | }); |
79 | 79 | |
80 | 80 | // Pass the real filename as the DAV display name |
81 | - $propFind->handle(FilesPlugin::DISPLAYNAME_PROPERTYNAME, function () use ($node) { |
|
81 | + $propFind->handle(FilesPlugin::DISPLAYNAME_PROPERTYNAME, function() use ($node) { |
|
82 | 82 | return $node->getFilename(); |
83 | 83 | }); |
84 | 84 | |
85 | - $propFind->handle(FilesPlugin::SIZE_PROPERTYNAME, function () use ($node) { |
|
85 | + $propFind->handle(FilesPlugin::SIZE_PROPERTYNAME, function() use ($node) { |
|
86 | 86 | return $node->getSize(); |
87 | 87 | }); |
88 | 88 | |
89 | - $propFind->handle(FilesPlugin::FILEID_PROPERTYNAME, function () use ($node) { |
|
89 | + $propFind->handle(FilesPlugin::FILEID_PROPERTYNAME, function() use ($node) { |
|
90 | 90 | return $node->getFileId(); |
91 | 91 | }); |
92 | 92 | |
93 | - $propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, function () { |
|
93 | + $propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, function() { |
|
94 | 94 | return 'GD'; // read + delete |
95 | 95 | }); |
96 | 96 | |
97 | - $propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, function () use ($node) { |
|
97 | + $propFind->handle(FilesPlugin::GETETAG_PROPERTYNAME, function() use ($node) { |
|
98 | 98 | // add fake etag, it is only needed to identify the preview image |
99 | 99 | return $node->getLastModified(); |
100 | 100 | }); |
101 | 101 | |
102 | - $propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, function () use ($node) { |
|
102 | + $propFind->handle(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, function() use ($node) { |
|
103 | 103 | // add fake etag, it is only needed to identify the preview image |
104 | 104 | return $node->getFileId(); |
105 | 105 | }); |
106 | 106 | |
107 | - $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node) { |
|
107 | + $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function() use ($node) { |
|
108 | 108 | return $this->previewManager->isAvailable($node->getFileInfo()); |
109 | 109 | }); |
110 | 110 | |
111 | - $propFind->handle(FilesPlugin::MOUNT_TYPE_PROPERTYNAME, function () { |
|
111 | + $propFind->handle(FilesPlugin::MOUNT_TYPE_PROPERTYNAME, function() { |
|
112 | 112 | return ''; |
113 | 113 | }); |
114 | 114 | |
115 | - $propFind->handle(self::TRASHBIN_BACKEND, function () use ($node) { |
|
115 | + $propFind->handle(self::TRASHBIN_BACKEND, function() use ($node) { |
|
116 | 116 | $fileInfo = $node->getFileInfo(); |
117 | 117 | if (!($fileInfo instanceof ITrashItem)) { |
118 | 118 | return ''; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $path = $request->getPath(); |
132 | 132 | $node = $this->server->tree->getNodeForPath($path); |
133 | 133 | if ($node instanceof ITrash) { |
134 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . $node->getFilename() . '"'); |
|
134 | + $response->addHeader('Content-Disposition', 'attachment; filename="'.$node->getFilename().'"'); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 |