From dd3f595b54f462c97dd6053f6781d873ae04f3d2 Mon Sep 17 00:00:00 2001 From: Zach Dykstra Date: Sun, 12 Mar 2023 13:37:12 -0500 Subject: [PATCH] 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 Reviewed-by: waddlesplash --- .../inbound_protocols/imap/IMAPProtocol.cpp | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPProtocol.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPProtocol.cpp index 443ef0365a..680c74c54a 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPProtocol.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPProtocol.cpp @@ -275,14 +275,24 @@ IMAPProtocol::_CreateFolder(const BString& mailbox, const BString& separator) return NULL; } - status_t 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; - } + status_t status; + BNode node(path.Path()); - CopyMailFolderAttributes(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);