Permalink
Browse files

- Cache synchronization using QRESYNC/CONDSTORE

- Fixed message ID updates in cache
- Changed message flags handling + some fixes (e.g. fixed messages listing after delete)
  • Loading branch information...
alecpl committed Sep 18, 2011
1 parent 30f5055 commit 609d3923d7dc674263ddea990387dbf5488fabc6
View
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Cache synchronization using QRESYNC/CONDSTORE
- Fix locked folder rename option on servers supporting RFC2086 only (#1488089)
- Trigger 'new_messages' hook for all checked folders (#1488083)
- Fix session race conditions when composing new messages
@@ -17,7 +18,6 @@ CHANGELOG Roundcube Webmail
Indexes are stored in a separate table, so there's no need to store all messages in a folder
Added threads data caching
Flags are stored separately, so flag change doesn't cause DELETE+INSERT, just UPDATE
-- Partial QRESYNC support
- Improved FETCH response handling
- Improvements in response tokenization method
- Use 'From' and 'To' labels instead of 'Sender' and 'Recipient'
View
@@ -11,6 +11,7 @@ CREATE TABLE [dbo].[cache_index] (
[user_id] [int] NOT NULL ,
[mailbox] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[changed] [datetime] NOT NULL ,
+ [valid] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL ,
[data] [text] COLLATE Latin1_General_CI_AI NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
@@ -29,12 +30,7 @@ CREATE TABLE [dbo].[cache_messages] (
[uid] [int] NOT NULL ,
[changed] [datetime] NOT NULL ,
[data] [text] COLLATE Latin1_General_CI_AI NOT NULL
- [seen] [char](1) NOT NULL ,
- [deleted] [char](1) NOT NULL ,
- [answered] [char](1) NOT NULL ,
- [forwarded] [char](1) NOT NULL ,
- [flagged] [char](1) NOT NULL ,
- [mdnsent] [char](1) NOT NULL ,
+ [flags] [int](1) NOT NULL ,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
@@ -229,12 +225,7 @@ GO
ALTER TABLE [dbo].[cache_messages] ADD
CONSTRAINT [DF_cache_messages_changed] DEFAULT (getdate()) FOR [changed]
- CONSTRAINT [DF_cache_messages_seen] DEFAULT (0) FOR [seen],
- CONSTRAINT [DF_cache_messages_deleted] DEFAULT (0) FOR [deleted],
- CONSTRAINT [DF_cache_messages_answered] DEFAULT (0) FOR [answered],
- CONSTRAINT [DF_cache_messages_forwarded] DEFAULT (0) FOR [forwarded],
- CONSTRAINT [DF_cache_messages_flagged] DEFAULT (0) FOR [flagged],
- CONSTRAINT [DF_cache_messages_mdnsent] DEFAULT (0) FOR [mdnsent],
+ CONSTRAINT [DF_cache_messages_flags] DEFAULT (0) FOR [flags],
GO
CREATE INDEX [IX_cache_messages_user_id] ON [dbo].[cache_messages]([user_id]) ON [PRIMARY]
View
@@ -175,12 +175,7 @@ CREATE TABLE [dbo].[cache_messages] (
[uid] [int] NOT NULL ,
[changed] [datetime] NOT NULL ,
[data] [text] COLLATE Latin1_General_CI_AI NOT NULL
- [seen] [char](1) NOT NULL ,
- [deleted] [char](1) NOT NULL ,
- [answered] [char](1) NOT NULL ,
- [forwarded] [char](1) NOT NULL ,
- [flagged] [char](1) NOT NULL ,
- [mdnsent] [char](1) NOT NULL ,
+ [flags] [int] NOT NULL ,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
@@ -220,13 +215,8 @@ CREATE INDEX [IX_cache_thread_user_id] ON [dbo].[cache_thread]([user_id]) ON [P
GO
ALTER TABLE [dbo].[cache_messages] ADD
- CONSTRAINT [DF_cache_messages_changed] DEFAULT (getdate()) FOR [changed]
- CONSTRAINT [DF_cache_messages_seen] DEFAULT (0) FOR [seen],
- CONSTRAINT [DF_cache_messages_deleted] DEFAULT (0) FOR [deleted],
- CONSTRAINT [DF_cache_messages_answered] DEFAULT (0) FOR [answered],
- CONSTRAINT [DF_cache_messages_forwarded] DEFAULT (0) FOR [forwarded],
- CONSTRAINT [DF_cache_messages_flagged] DEFAULT (0) FOR [flagged],
- CONSTRAINT [DF_cache_messages_mdnsent] DEFAULT (0) FOR [mdnsent],
+ CONSTRAINT [DF_cache_messages_changed] DEFAULT (getdate()) FOR [changed],
+ CONSTRAINT [DF_cache_messages_flags] DEFAULT (0) FOR [flags]
GO
CREATE INDEX [IX_cache_messages_user_id] ON [dbo].[cache_messages]([user_id]) ON [PRIMARY]
View
@@ -55,6 +55,7 @@ CREATE TABLE `cache_index` (
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`mailbox` varchar(255) BINARY NOT NULL,
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
+ `valid` tinyint(1) NOT NULL DEFAULT '0',
`data` longtext NOT NULL,
CONSTRAINT `user_id_fk_cache_index` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
@@ -85,12 +86,7 @@ CREATE TABLE `cache_messages` (
`uid` int(11) UNSIGNED NOT NULL DEFAULT '0',
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`data` longtext NOT NULL,
- `seen` tinyint(1) NOT NULL DEFAULT '0',
- `deleted` tinyint(1) NOT NULL DEFAULT '0',
- `answered` tinyint(1) NOT NULL DEFAULT '0',
- `forwarded` tinyint(1) NOT NULL DEFAULT '0',
- `flagged` tinyint(1) NOT NULL DEFAULT '0',
- `mdnsent` tinyint(1) NOT NULL DEFAULT '0',
+ `flags` int(11) NOT NULL DEFAULT '0',
CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX `changed_index` (`changed`),
View
@@ -201,12 +201,7 @@ CREATE TABLE `cache_messages` (
`uid` int(11) UNSIGNED NOT NULL DEFAULT '0',
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`data` longtext NOT NULL,
- `seen` tinyint(1) NOT NULL DEFAULT '0',
- `deleted` tinyint(1) NOT NULL DEFAULT '0',
- `answered` tinyint(1) NOT NULL DEFAULT '0',
- `forwarded` tinyint(1) NOT NULL DEFAULT '0',
- `flagged` tinyint(1) NOT NULL DEFAULT '0',
- `mdnsent` tinyint(1) NOT NULL DEFAULT '0',
+ `flags` int(11) NOT NULL DEFAULT '0',
CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX `changed_index` (`changed`),
View
@@ -197,6 +197,7 @@ CREATE TABLE cache_index (
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
mailbox varchar(255) NOT NULL,
changed timestamp with time zone DEFAULT now() NOT NULL,
+ valid smallint NOT NULL DEFAULT 0,
data text NOT NULL,
PRIMARY KEY (user_id, mailbox)
);
@@ -231,12 +232,7 @@ CREATE TABLE cache_messages (
uid integer NOT NULL,
changed timestamp with time zone DEFAULT now() NOT NULL,
data text NOT NULL,
- seen smallint NOT NULL DEFAULT 0,
- deleted smallint NOT NULL DEFAULT 0,
- answered smallint NOT NULL DEFAULT 0,
- forwarded smallint NOT NULL DEFAULT 0,
- flagged smallint NOT NULL DEFAULT 0,
- mdnsent smallint NOT NULL DEFAULT 0,
+ flags integer NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, mailbox, uid)
);
View
@@ -159,12 +159,7 @@ CREATE TABLE cache_messages (
uid integer NOT NULL,
changed timestamp with time zone DEFAULT now() NOT NULL,
data text NOT NULL,
- seen smallint NOT NULL DEFAULT 0,
- deleted smallint NOT NULL DEFAULT 0,
- answered smallint NOT NULL DEFAULT 0,
- forwarded smallint NOT NULL DEFAULT 0,
- flagged smallint NOT NULL DEFAULT 0,
- mdnsent smallint NOT NULL DEFAULT 0,
+ flags integer NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, mailbox, uid)
);
View
@@ -159,6 +159,7 @@ CREATE TABLE cache_index (
user_id integer NOT NULL,
mailbox varchar(255) NOT NULL,
changed datetime NOT NULL default '0000-00-00 00:00:00',
+ valid smallint NOT NULL DEFAULT '0',
data text NOT NULL,
PRIMARY KEY (user_id, mailbox)
);
@@ -193,12 +194,7 @@ CREATE TABLE cache_messages (
uid integer NOT NULL,
changed datetime NOT NULL default '0000-00-00 00:00:00',
data text NOT NULL,
- seen smallint NOT NULL DEFAULT '0',
- deleted smallint NOT NULL DEFAULT '0',
- answered smallint NOT NULL DEFAULT '0',
- forwarded smallint NOT NULL DEFAULT '0',
- flagged smallint NOT NULL DEFAULT '0',
- mdnsent smallint NOT NULL DEFAULT '0',
+ flags integer NOT NULL DEFAULT '0',
PRIMARY KEY (user_id, mailbox, uid)
);
View
@@ -276,12 +276,7 @@ CREATE TABLE cache_messages (
uid integer NOT NULL,
changed datetime NOT NULL default '0000-00-00 00:00:00',
data text NOT NULL,
- seen smallint NOT NULL DEFAULT '0',
- deleted smallint NOT NULL DEFAULT '0',
- answered smallint NOT NULL DEFAULT '0',
- forwarded smallint NOT NULL DEFAULT '0',
- flagged smallint NOT NULL DEFAULT '0',
- mdnsent smallint NOT NULL DEFAULT '0',
+ flags integer NOT NULL DEFAULT '0',
PRIMARY KEY (user_id, mailbox, uid)
);
@@ -813,7 +813,7 @@ function list_headers($mailbox='', $page=NULL, $sort_field=NULL, $sort_order=NUL
$mailbox = $this->mailbox;
}
- return $this->_list_headers($mailbox, $page, $sort_field, $sort_order, false, $slice);
+ return $this->_list_headers($mailbox, $page, $sort_field, $sort_order, $slice);
}
@@ -1086,7 +1086,7 @@ private function _set_thread_flags(&$headers, $msg_depth, $msg_children)
if (!empty($parents)) {
$headers[$idx]->parent_uid = end($parents);
- if (!$header->seen)
+ if (empty($header->flags['SEEN']))
$headers[$parents[0]]->unread_children++;
}
array_push($parents, $header->uid);
@@ -3421,6 +3421,8 @@ function mailbox_data($mailbox)
if ($this->conn->selected != $mailbox) {
if ($this->conn->select($mailbox))
$this->mailbox = $mailbox;
+ else
+ return null;
}
$data = $this->conn->data;
@@ -3516,6 +3518,19 @@ function mailbox_info($mailbox)
}
+ /**
+ * Synchronizes messages cache.
+ *
+ * @param string $mailbox Folder name
+ */
+ public function mailbox_sync($mailbox)
+ {
+ if ($mcache = $this->get_mcache_engine()) {
+ $mcache->synchronize($mailbox);
+ }
+ }
+
+
/**
* Get message header names for rcube_imap_generic::fetchHeader(s)
*
Oops, something went wrong.

0 comments on commit 609d392

Please sign in to comment.