changeset 7173:9841a8563116 HEAD

Don't re-read maildirsize if it hasn't changed.
author Timo Sirainen <tss@iki.fi>
date Sun, 20 Jan 2008 08:54:57 +0200
parents 097fe25ab218
children f090b6bf8021
files src/plugins/quota/quota-maildir.c
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-maildir.c	Sun Jan 20 08:49:36 2008 +0200
+++ b/src/plugins/quota/quota-maildir.c	Sun Jan 20 08:54:57 2008 +0200
@@ -460,12 +460,36 @@
 	return 1;
 }
 
+static bool maildirsize_has_changed(struct maildir_quota_root *root)
+{
+	struct stat st1, st2;
+
+	if (dotlock_settings.nfs_flush) {
+		nfs_flush_file_handle_cache(root->maildirsize_path);
+		nfs_flush_attr_cache_unlocked(root->maildirsize_path);
+	}
+
+	if (root->fd == -1)
+		return TRUE;
+
+	if (stat(root->maildirsize_path, &st1) < 0)
+		return TRUE;
+	if (fstat(root->fd, &st2) < 0)
+		return TRUE;
+
+	return st1.st_size != st2.st_size || st1.st_ino != st2.st_ino ||
+		!CMP_DEV_T(st1.st_dev, st2.st_dev);
+}
+
 static int maildirsize_read(struct maildir_quota_root *root)
 {
 	char buf[5120+1];
 	unsigned int i, size;
 	int ret;
 
+	if (!maildirsize_has_changed(root))
+		return 1;
+
 	if ((ret = maildirsize_open(root)) <= 0)
 		return ret;