Skip to content

Commit 45de5f1

Browse files
fix(GODT-2418): Do not issue connector renames for inferiors
When renaming a mailbox with inferiors, do not issue rename requests to the connector for the inferiors. The connector should internally handle this. We should only rename the mailboxes locally to avoid waiting on the connector event.
1 parent 9f7c827 commit 45de5f1

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

internal/state/state.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ func (state *State) Rename(ctx context.Context, oldName, newName string) error {
371371
return state.renameInbox(ctx, tx, mbox, newName)
372372
}
373373

374+
if err := state.actionUpdateMailbox(ctx, tx, mbox.RemoteID, newName); err != nil {
375+
return err
376+
}
377+
378+
// Locally update all inferiors so we don't wait for update
374379
mailboxes, err := db.GetAllMailboxes(ctx, tx.Client())
375380
if err != nil {
376381
return err
@@ -388,12 +393,12 @@ func (state *State) Rename(ctx context.Context, oldName, newName string) error {
388393

389394
newInferior := newName + strings.TrimPrefix(inferior, oldName)
390395

391-
if err := state.actionUpdateMailbox(ctx, tx, mbox.RemoteID, newInferior); err != nil {
396+
if err := db.RenameMailboxWithRemoteID(ctx, tx, mbox.RemoteID, newInferior); err != nil {
392397
return err
393398
}
394399
}
395400

396-
return state.actionUpdateMailbox(ctx, tx, mbox.RemoteID, newName)
401+
return nil
397402
})
398403
}
399404

tests/rename_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ func TestRenameHierarchy(t *testing.T) {
3838
})
3939
}
4040

41+
func TestRenameHierarchyRoot(t *testing.T) {
42+
runOneToOneTestClientWithAuth(t, defaultServerOptions(t), func(client *client.Client, _ *testSession) {
43+
require.NoError(t, client.Create("foo/bar/zap"))
44+
45+
matchMailboxNamesClient(t, client, "", "*", []string{"INBOX", "foo", "foo/bar", "foo/bar/zap"})
46+
47+
require.NoError(t, client.Rename("foo", "baz"))
48+
49+
matchMailboxNamesClient(t, client, "", "*", []string{"INBOX", "baz", "baz/bar", "baz/bar/zap"})
50+
})
51+
}
52+
4153
func TestRenameAddHierarchy(t *testing.T) {
4254
type renameTC struct {
4355
src string

0 commit comments

Comments
 (0)