1717use OCA \Files_External \Service \UserGlobalStoragesService ;
1818use OCA \Files_External \Service \UserStoragesService ;
1919use OCP \AppFramework \QueryException ;
20+ use OCP \Files \Config \IAuthoritativeMountProvider ;
2021use OCP \Files \Config \IMountProvider ;
2122use OCP \Files \Mount \IMountPoint ;
2223use OCP \Files \ObjectStore \IObjectStore ;
3233/**
3334 * Make the old files_external config work with the new public mount config api
3435 */
35- class ConfigAdapter implements IMountProvider {
36+ class ConfigAdapter implements IMountProvider, IAuthoritativeMountProvider {
3637 public function __construct (
3738 private UserStoragesService $ userStoragesService ,
3839 private UserGlobalStoragesService $ userGlobalStoragesService ,
@@ -73,6 +74,11 @@ private function prepareStorageConfig(StorageConfig &$storage, IUser $user): voi
7374 $ storage ->getBackend ()->manipulateStorageConfig ($ storage , $ user );
7475 }
7576
77+ public function constructStorageForUser (IUser $ user , StorageConfig $ storage ) {
78+ $ this ->prepareStorageConfig ($ storage , $ user );
79+ return $ this ->constructStorage ($ storage );
80+ }
81+
7682 /**
7783 * Construct the storage implementation
7884 *
@@ -105,8 +111,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
105111
106112 $ storages = array_map (function (StorageConfig $ storageConfig ) use ($ user ) {
107113 try {
108- $ this ->prepareStorageConfig ($ storageConfig , $ user );
109- return $ this ->constructStorage ($ storageConfig );
114+ return $ this ->constructStorageForUser ($ user , $ storageConfig );
110115 } catch (\Exception $ e ) {
111116 // propagate exception into filesystem
112117 return new FailedStorage (['exception ' => $ e ]);
@@ -123,7 +128,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
123128 $ availability = $ storage ->getAvailability ();
124129 if (!$ availability ['available ' ] && !Availability::shouldRecheck ($ availability )) {
125130 $ storage = new FailedStorage ([
126- 'exception ' => new StorageNotAvailableException ('Storage with mount id ' . $ storageConfig ->getId () . ' is not available ' )
131+ 'exception ' => new StorageNotAvailableException ('Storage with mount id ' . $ storageConfig ->getId () . ' is not available ' ),
127132 ]);
128133 }
129134 } catch (\Exception $ e ) {
@@ -148,7 +153,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
148153 null ,
149154 $ loader ,
150155 $ storageConfig ->getMountOptions (),
151- $ storageConfig ->getId ()
156+ $ storageConfig ->getId (),
152157 );
153158 } else {
154159 return new SystemMountPoint (
@@ -158,7 +163,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
158163 null ,
159164 $ loader ,
160165 $ storageConfig ->getMountOptions (),
161- $ storageConfig ->getId ()
166+ $ storageConfig ->getId (),
162167 );
163168 }
164169 }, $ storageConfigs , $ availableStorages );
0 commit comments