@@ -179,7 +179,7 @@ class AccountRepository @Inject constructor(
179
179
* @throws IllegalArgumentException if the new account name already exists
180
180
* @throws Exception (or sub-classes) on other errors
181
181
*/
182
- suspend fun rename (oldName : String , newName : String ) {
182
+ suspend fun rename (oldName : String , newName : String ): Unit = withContext(defaultDispatcher) {
183
183
val oldAccount = fromName(oldName)
184
184
val newAccount = fromName(newName)
185
185
@@ -201,13 +201,10 @@ class AccountRepository @Inject constructor(
201
201
// rename account (also moves AccountSettings)
202
202
val future = accountManager.renameAccount(oldAccount, newName, null , null )
203
203
204
- // wait for operation to complete
205
- withContext(defaultDispatcher) {
206
- // blocks calling thread
207
- val newNameFromApi: Account = future.result
208
- if (newNameFromApi.name != newName)
209
- throw IllegalStateException (" renameAccount returned ${newNameFromApi.name} instead of $newName " )
210
- }
204
+ // wait for operation to complete (blocks calling thread)
205
+ val newNameFromApi: Account = future.result
206
+ if (newNameFromApi.name != newName)
207
+ throw IllegalStateException (" renameAccount returned ${newNameFromApi.name} instead of $newName " )
211
208
212
209
// account renamed, cancel maybe running synchronization of old account
213
210
syncWorkerManager.get().cancelAllWork(oldAccount)
@@ -242,9 +239,7 @@ class AccountRepository @Inject constructor(
242
239
}
243
240
244
241
// update automatic sync
245
- withContext(defaultDispatcher) {
246
- automaticSyncManager.get().updateAutomaticSync(newAccount)
247
- }
242
+ automaticSyncManager.get().updateAutomaticSync(newAccount)
248
243
} finally {
249
244
// release AccountsCleanupWorker mutex at the end of this async coroutine
250
245
AccountsCleanupWorker .unlockAccountsCleanup()
0 commit comments