Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25b2019f authored by Jonathan Klee's avatar Jonathan Klee
Browse files

fix(import): drop stale API cache before loading capabilities

ApiProvider caches NextcloudAPI by accountName, so a re-import of the same Murena Workspace account reused the previous instance with its now-stale SSO token and the very first capabilities call failed with "Invalid token".
parent 63800551
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -137,6 +137,10 @@ public class ImportAccountActivity extends AppCompatActivity {
                SingleAccountHelper.commitCurrentAccount(getApplicationContext(), ssoAccount.name);
                executor.submit(() -> {
                    Log.i(TAG, "Added account: " + "name:" + ssoAccount.name + ", " + ssoAccount.url + ", userId" + ssoAccount.userId);
                    // Drop any NextcloudAPI / OcsAPI cached for an earlier import of the same
                    // account name — its SSO token is now stale and would cause an "Invalid
                    // token" on the very first capabilities call.
                    ApiProvider.getInstance().invalidateAPICache(ssoAccount);
                    try {
                        Log.i(TAG, "Loading capabilities for " + ssoAccount.name);
                        final var capabilities = CapabilitiesClient.getCapabilities(getApplicationContext(), ssoAccount, null, ApiProvider.getInstance());