mail: only copy attributes for new IMAP folders

When mail_daemon associates a subscribed IMAP folder with a local
folder, ~/config/settings/Tracker/DefaultQueryTemplates/text_x-email
attributes are duplicated to the folder. Any customizations (column
layout, window size / location, etc) are overwritten by the values set
for text_x-email. The text_x-email template folder was originally meant
to be used by the 'New E-mail' query. In particular, the columns that
might be set for the query view aren't directly useful for an IMAP
folder - Account is useful for the query view, but not for an IMAP
folder, Status is not useful for the query view, but useful for an IMAP
folder.

This behavior is now modified such that attributes are only copied the
first time an IMAP folder is created. Subsequent launches of mail_daemon
will not overwrite per-folder customizations.

Fixes #18297

Change-Id: Iacdc78403681d5546668f28f7f0e34d1a57fd410
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6202
Tested-by: Automation <automation@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Zach Dykstra 2023-03-12 13:37:12 -05:00 committed by waddlesplash
parent 304569520d
commit dd3f595b54

View File

@ -275,14 +275,24 @@ IMAPProtocol::_CreateFolder(const BString& mailbox, const BString& separator)
return NULL;
}
status_t status = create_directory(path.Path(), 0755);
status_t status;
BNode node(path.Path());
if (node.InitCheck() == B_OK) {
if (!node.IsDirectory()) {
fprintf(stderr, "%s already exists and is not a directory\n",
path.Path());
return NULL;
}
} else {
status = create_directory(path.Path(), 0755);
if (status != B_OK) {
fprintf(stderr, "Could not create path %s: %s\n", path.Path(),
strerror(status));
return NULL;
}
CopyMailFolderAttributes(path.Path());
}
entry_ref ref;
status = get_ref_for_path(path.Path(), &ref);