mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
Let MailboxManager#unPair() return a boolean for whether it could wipe the mailbox
This commit is contained in:
@@ -45,7 +45,11 @@ public interface MailboxManager {
|
|||||||
/**
|
/**
|
||||||
* Unpairs the owner's mailbox and tries to wipe it.
|
* Unpairs the owner's mailbox and tries to wipe it.
|
||||||
* As this makes a network call, it should be run on the {@link IoExecutor}.
|
* As this makes a network call, it should be run on the {@link IoExecutor}.
|
||||||
|
*
|
||||||
|
* @return true if we could wipe the mailbox, false if we couldn't.
|
||||||
|
* It is advised to inform the user to wipe the mailbox themselves,
|
||||||
|
* if we failed to wipe it.
|
||||||
*/
|
*/
|
||||||
@IoExecutor
|
@IoExecutor
|
||||||
void unPair() throws DbException;
|
boolean unPair() throws DbException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,17 +132,19 @@ class MailboxManagerImpl implements MailboxManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unPair() throws DbException {
|
public boolean unPair() throws DbException {
|
||||||
MailboxProperties properties = db.transactionWithNullableResult(true,
|
MailboxProperties properties = db.transactionWithNullableResult(true,
|
||||||
mailboxSettingsManager::getOwnMailboxProperties);
|
mailboxSettingsManager::getOwnMailboxProperties);
|
||||||
|
boolean wasWiped;
|
||||||
try {
|
try {
|
||||||
api.wipeMailbox(properties);
|
api.wipeMailbox(properties);
|
||||||
|
wasWiped = true;
|
||||||
} catch (IOException | MailboxApi.ApiException e) {
|
} catch (IOException | MailboxApi.ApiException e) {
|
||||||
// We wipe on a best-effort basis.
|
|
||||||
// If we can't do it, we still unpair.
|
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
|
wasWiped = false;
|
||||||
}
|
}
|
||||||
db.transaction(false,
|
db.transaction(false,
|
||||||
mailboxSettingsManager::removeOwnMailboxProperties);
|
mailboxSettingsManager::removeOwnMailboxProperties);
|
||||||
|
return wasWiped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user