mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 14:45:47 +03:00
Merge pull request #9644 from nextcloud/cleanUpAccountRemoval
Clean up AccountRemovalWork
This commit is contained in:
commit
7d4fa2994c
2 changed files with 13 additions and 5 deletions
|
@ -32,6 +32,7 @@ import com.google.gson.Gson
|
||||||
import com.nextcloud.client.account.User
|
import com.nextcloud.client.account.User
|
||||||
import com.nextcloud.client.account.UserAccountManager
|
import com.nextcloud.client.account.UserAccountManager
|
||||||
import com.nextcloud.client.core.Clock
|
import com.nextcloud.client.core.Clock
|
||||||
|
import com.nextcloud.client.preferences.AppPreferences
|
||||||
import com.nextcloud.client.preferences.AppPreferencesImpl
|
import com.nextcloud.client.preferences.AppPreferencesImpl
|
||||||
import com.nextcloud.common.NextcloudClient
|
import com.nextcloud.common.NextcloudClient
|
||||||
import com.nextcloud.java.util.Optional
|
import com.nextcloud.java.util.Optional
|
||||||
|
@ -70,7 +71,8 @@ class AccountRemovalWork(
|
||||||
private val userAccountManager: UserAccountManager,
|
private val userAccountManager: UserAccountManager,
|
||||||
private val backgroundJobManager: BackgroundJobManager,
|
private val backgroundJobManager: BackgroundJobManager,
|
||||||
private val clock: Clock,
|
private val clock: Clock,
|
||||||
private val eventBus: EventBus
|
private val eventBus: EventBus,
|
||||||
|
private val preferences: AppPreferences
|
||||||
) : Worker(context, params) {
|
) : Worker(context, params) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -109,7 +111,7 @@ class AccountRemovalWork(
|
||||||
arbitraryDataProvider.deleteKeyForAccount(user.accountName, ManageAccountsActivity.PENDING_FOR_REMOVAL)
|
arbitraryDataProvider.deleteKeyForAccount(user.accountName, ManageAccountsActivity.PENDING_FOR_REMOVAL)
|
||||||
|
|
||||||
// remove synced folders set for account
|
// remove synced folders set for account
|
||||||
remoceSyncedFolders(context, user.toPlatformAccount(), clock)
|
removeSyncedFolders(context, user.toPlatformAccount(), clock)
|
||||||
|
|
||||||
// delete all uploads for account
|
// delete all uploads for account
|
||||||
uploadsStorageManager.removeUserUploads(user)
|
uploadsStorageManager.removeUserUploads(user)
|
||||||
|
@ -119,6 +121,11 @@ class AccountRemovalWork(
|
||||||
arbitraryDataProvider.deleteKeyForAccount(user.accountName, EncryptionUtils.PUBLIC_KEY)
|
arbitraryDataProvider.deleteKeyForAccount(user.accountName, EncryptionUtils.PUBLIC_KEY)
|
||||||
arbitraryDataProvider.deleteKeyForAccount(user.accountName, EncryptionUtils.MNEMONIC)
|
arbitraryDataProvider.deleteKeyForAccount(user.accountName, EncryptionUtils.MNEMONIC)
|
||||||
|
|
||||||
|
// unset default account, if needed
|
||||||
|
if (preferences.currentAccountName.equals(user.accountName)) {
|
||||||
|
preferences.currentAccountName = ""
|
||||||
|
}
|
||||||
|
|
||||||
// remove all files
|
// remove all files
|
||||||
removeFiles(user, storageManager)
|
removeFiles(user, storageManager)
|
||||||
// delete all database entries
|
// delete all database entries
|
||||||
|
@ -173,7 +180,7 @@ class AccountRemovalWork(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun remoceSyncedFolders(context: Context, account: Account, clock: Clock) {
|
private fun removeSyncedFolders(context: Context, account: Account, clock: Clock) {
|
||||||
val syncedFolderProvider = SyncedFolderProvider(
|
val syncedFolderProvider = SyncedFolderProvider(
|
||||||
context.contentResolver,
|
context.contentResolver,
|
||||||
AppPreferencesImpl.fromContext(context),
|
AppPreferencesImpl.fromContext(context),
|
||||||
|
@ -189,7 +196,7 @@ class AccountRemovalWork(
|
||||||
syncedFolderProvider.deleteSyncFoldersForAccount(account)
|
syncedFolderProvider.deleteSyncFoldersForAccount(account)
|
||||||
val filesystemDataProvider = FilesystemDataProvider(context.contentResolver)
|
val filesystemDataProvider = FilesystemDataProvider(context.contentResolver)
|
||||||
for (syncedFolderId in syncedFolderIds) {
|
for (syncedFolderId in syncedFolderIds) {
|
||||||
filesystemDataProvider.deleteAllEntriesForSyncedFolder(java.lang.Long.toString(syncedFolderId))
|
filesystemDataProvider.deleteAllEntriesForSyncedFolder(syncedFolderId.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||||
accountManager,
|
accountManager,
|
||||||
backgroundJobManager.get(),
|
backgroundJobManager.get(),
|
||||||
clock,
|
clock,
|
||||||
eventBus
|
eventBus,
|
||||||
|
preferences
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue