File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ protected function validate(StorageConfig $storage) {
140140 $ backend = $ storage ->getBackend ();
141141 /** @var AuthMechanism */
142142 $ authMechanism = $ storage ->getAuthMechanism ();
143- if ($ backend ->checkDependencies ()) {
143+ if ($ backend ->checkRequiredDependencies ()) {
144144 // invalid backend
145145 return new DataResponse (
146146 [
Original file line number Diff line number Diff line change 1515trait DependencyTrait {
1616
1717 /**
18- * Check if object is valid for use
18+ * Check if object has unsatisfied required or optional dependencies
1919 *
2020 * @return MissingDependency[] Unsatisfied dependencies
2121 */
2222 public function checkDependencies () {
2323 return []; // no dependencies by default
2424 }
25+
26+ /**
27+ * Check if object has unsatisfied required dependencies
28+ *
29+ * @return MissingDependency[] Unsatisfied required dependencies
30+ */
31+ public function checkRequiredDependencies () {
32+ return array_filter (
33+ $ this ->checkDependencies (),
34+ fn (MissingDependency $ dependency ) => !$ dependency ->isOptional ()
35+ );
36+ }
2537}
Original file line number Diff line number Diff line change 1414use OCA \Files_External \Lib \Backend \Backend ;
1515use OCA \Files_External \Lib \Config \IAuthMechanismProvider ;
1616use OCA \Files_External \Lib \Config \IBackendProvider ;
17- use OCA \Files_External \Lib \MissingDependency ;
1817use OCP \EventDispatcher \GenericEvent ;
1918use OCP \EventDispatcher \IEventDispatcher ;
2019use OCP \IAppConfig ;
@@ -179,10 +178,7 @@ public function getBackends() {
179178 * @return Backend[]
180179 */
181180 public function getAvailableBackends () {
182- return array_filter ($ this ->getBackends (), function ($ backend ) {
183- $ missing = array_filter ($ backend ->checkDependencies (), fn (MissingDependency $ dependency ) => !$ dependency ->isOptional ());
184- return count ($ missing ) === 0 ;
185- });
181+ return array_filter ($ this ->getBackends (), fn (Backend $ backend ) => !$ backend ->checkRequiredDependencies ());
186182 }
187183
188184 /**
Original file line number Diff line number Diff line change @@ -175,11 +175,11 @@ public function testGetAvailableBackends(): void {
175175
176176 $ backendAvailable = $ this ->getBackendMock ('\Backend\Available ' );
177177 $ backendAvailable ->expects ($ this ->once ())
178- ->method ('checkDependencies ' )
178+ ->method ('checkRequiredDependencies ' )
179179 ->willReturn ([]);
180180 $ backendNotAvailable = $ this ->getBackendMock ('\Backend\NotAvailable ' );
181181 $ backendNotAvailable ->expects ($ this ->once ())
182- ->method ('checkDependencies ' )
182+ ->method ('checkRequiredDependencies ' )
183183 ->willReturn ([
184184 $ this ->getMockBuilder ('\OCA\Files_External\Lib\MissingDependency ' )
185185 ->disableOriginalConstructor ()
You can’t perform that action at this time.
0 commit comments