1515use OCP \AppFramework \Http ;
1616use OCP \Constants ;
1717use OCP \Diagnostics \IEventLogger ;
18+ use OCP \EventDispatcher \IEventDispatcher ;
19+ use OCP \Files \Events \BeforePropfindEvent ;
1820use OCP \Files \FileInfo ;
1921use OCP \Files \ForbiddenException ;
2022use OCP \Files \IMimeTypeDetector ;
@@ -232,6 +234,34 @@ public function opendir(string $path) {
232234 return false ;
233235 }
234236
237+ /**
238+ * @return array<string>
239+ */
240+ protected function getPropfindProperties (): array {
241+ $ event = new BeforePropfindEvent (self ::PROPFIND_PROPS );
242+ Server::get (IEventDispatcher::class)->dispatchTyped ($ event );
243+ return $ event ->getProperties ();
244+ }
245+
246+ /**
247+ * Get property value from cached PROPFIND response.
248+ * For accessing app-specific properties not included in getMetaData().
249+ *
250+ * @param string $path
251+ * @param string $propertyName
252+ * @return mixed
253+ */
254+ public function getPropfindPropertyValue (string $ path , string $ propertyName ): mixed {
255+ $ path = $ this ->cleanPath ($ path );
256+ $ propfindResponse = $ this ->statCache ->get ($ path );
257+
258+ if (!is_array ($ propfindResponse )) {
259+ return null ;
260+ }
261+
262+ return $ propfindResponse [$ propertyName ] ?? null ;
263+ }
264+
235265 /**
236266 * Propfind call with cache handling.
237267 *
@@ -254,7 +284,7 @@ protected function propfind(string $path): array|false {
254284 try {
255285 $ response = $ this ->client ->propFind (
256286 $ this ->encodePath ($ path ),
257- self :: PROPFIND_PROPS
287+ $ this -> getPropfindProperties ()
258288 );
259289 $ this ->statCache ->set ($ path , $ response );
260290 } catch (ClientHttpException $ e ) {
@@ -818,7 +848,7 @@ public function getDirectoryContent(string $directory): \Traversable {
818848 try {
819849 $ responses = $ this ->client ->propFind (
820850 $ this ->encodePath ($ directory ),
821- self :: PROPFIND_PROPS ,
851+ $ this -> getPropfindProperties () ,
822852 1
823853 );
824854
0 commit comments