mirror of
https://github.com/mjl-/mox.git
synced 2025-07-13 14:54:35 +03:00
When removing an account, wait for the last account reference has gone away before removing the files.
The intent to remove the account is stored in the database. At startup, if there are any such referenes, they are applied by removing the account directories and the entry in the database. This ensures the account directory is properly removed, even on incomplete shutdown. Don't add an account when its directory already exits.
This commit is contained in:
@ -313,15 +313,13 @@ func LoginAttemptCleanup(ctx context.Context) error {
|
||||
})
|
||||
}
|
||||
|
||||
// LoginAttemptRemoveAccount removes all LoginAttempt records for an account
|
||||
// loginAttemptRemoveAccount removes all LoginAttempt records for an account
|
||||
// (value must be non-empty).
|
||||
func LoginAttemptRemoveAccount(ctx context.Context, accountName string) error {
|
||||
return AuthDB.Write(ctx, func(tx *bstore.Tx) error {
|
||||
q := bstore.QueryTx[LoginAttempt](tx)
|
||||
q.FilterNonzero(LoginAttempt{AccountName: accountName})
|
||||
_, err := q.Delete()
|
||||
return err
|
||||
})
|
||||
func loginAttemptRemoveAccount(tx *bstore.Tx, accountName string) error {
|
||||
q := bstore.QueryTx[LoginAttempt](tx)
|
||||
q.FilterNonzero(LoginAttempt{AccountName: accountName})
|
||||
_, err := q.Delete()
|
||||
return err
|
||||
}
|
||||
|
||||
// LoginAttemptList returns LoginAttempt records for the accountName. If
|
||||
|
Reference in New Issue
Block a user