Optimized isync by not fetching the sizes of messages if they are
unneeded (i.e., if MaxSize is not specified in the config file). Patch and idea originally from Nicolas Boullis <nboullis@debian.org>, modified/polished by Theodore Ts'o per comments by Oswald Buddenhagen.
This commit is contained in:
parent
180f5fa201
commit
0121220339
2
debian/patches/00list
vendored
2
debian/patches/00list
vendored
|
@ -1,3 +1 @@
|
|||
10-size-opt.dpatch
|
||||
20-cleanup.dpatch
|
||||
|
||||
|
|
81
debian/patches/10-size-opt.dpatch
vendored
81
debian/patches/10-size-opt.dpatch
vendored
|
@ -1,81 +0,0 @@
|
|||
#! /bin/sh -e
|
||||
## 10-size-opt.dpatch by Nicolas Boullis <nboullis@debian.org>
|
||||
##
|
||||
## DP: This patch from Nicolas Boullis <nboullis@debian.org> optimizes isync
|
||||
## DP: by not fetching the sizes of messages if they are unneeded (i.e., if
|
||||
## DP: MaxSize is not specified in the config file).
|
||||
|
||||
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
|
||||
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
|
||||
exit 1
|
||||
fi
|
||||
case "$1" in
|
||||
-patch) patch $patch_opts -p1 < $0;;
|
||||
-unpatch) patch $patch_opts -p1 -R < $0;;
|
||||
*)
|
||||
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@DPATCH@
|
||||
|
||||
===================================================================
|
||||
RCS file: isync-0.9.2/src/RCS/isync.h,v
|
||||
retrieving revision 1.1
|
||||
diff -u -r1.1 isync-0.9.2/src/isync.h
|
||||
--- isync-0.9.2/src/isync.h 2004/01/09 23:06:52 1.1
|
||||
+++ isync-0.9.2/src/isync.h 2004/01/09 23:07:08
|
||||
@@ -205,7 +205,7 @@
|
||||
int imap_set_flags (imap_t *, unsigned int, unsigned int);
|
||||
int imap_expunge (imap_t *);
|
||||
imap_t *imap_connect (config_t *);
|
||||
-imap_t *imap_open (config_t *, unsigned int, imap_t *, int);
|
||||
+imap_t *imap_open (config_t *, unsigned int, imap_t *, int, int);
|
||||
int imap_append_message (imap_t *, int, message_t *);
|
||||
int imap_list (imap_t *);
|
||||
|
||||
===================================================================
|
||||
RCS file: isync-0.9.2/src/RCS/imap.c,v
|
||||
retrieving revision 1.1
|
||||
diff -u -r1.1 isync-0.9.2/src/imap.c
|
||||
--- isync-0.9.2/src/imap.c 2004/01/09 23:08:20 1.1
|
||||
+++ isync-0.9.2/src/imap.c 2004/01/09 23:09:54
|
||||
@@ -874,7 +874,8 @@
|
||||
* mailbox.
|
||||
*/
|
||||
imap_t *
|
||||
-imap_open (config_t * box, unsigned int minuid, imap_t * imap, int imap_create)
|
||||
+imap_open (config_t * box, unsigned int minuid, imap_t * imap,
|
||||
+ int imap_create, int get_size)
|
||||
{
|
||||
if (imap)
|
||||
{
|
||||
@@ -940,7 +941,8 @@
|
||||
imap->minuid = minuid;
|
||||
if (imap->count > 0)
|
||||
{
|
||||
- if (imap_exec (imap, "UID FETCH %d:* (FLAGS RFC822.SIZE)", minuid))
|
||||
+ if (imap_exec (imap, "UID FETCH %d:* (FLAGS%s)", minuid,
|
||||
+ get_size ? " RFC822.SIZE" : ""))
|
||||
goto bail;
|
||||
}
|
||||
|
||||
===================================================================
|
||||
RCS file: isync-0.9.2/src/RCS/main.c,v
|
||||
retrieving revision 1.1
|
||||
diff -u -r1.1 isync-0.9.2/src/main.c
|
||||
--- isync-0.9.2/src/main.c 2004/01/09 23:08:20 1.1
|
||||
+++ isync-0.9.2/src/main.c 2004/01/09 23:08:31
|
||||
@@ -396,7 +396,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
- imap = imap_open (box, fast ? mail->maxuid + 1 : 1, imap, imap_create);
|
||||
+ imap = imap_open (box, fast ? mail->maxuid + 1 : 1, imap, imap_create, box->max_size!=0);
|
||||
if (!imap)
|
||||
{
|
||||
fprintf (stderr, "%s: skipping mailbox due to IMAP error\n",
|
|
@ -874,7 +874,7 @@ mstrcmp (const char *s1, const char *s2)
|
|||
* mailbox.
|
||||
*/
|
||||
imap_t *
|
||||
imap_open (config_t * box, unsigned int minuid, imap_t * imap, int imap_create)
|
||||
imap_open (config_t * box, unsigned int minuid, imap_t * imap, int imap_flags)
|
||||
{
|
||||
if (imap)
|
||||
{
|
||||
|
@ -926,7 +926,7 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap, int imap_create)
|
|||
info ("Selecting IMAP mailbox... ");
|
||||
fflush (stdout);
|
||||
if (imap_exec (imap, "SELECT \"%s%s\"", imap->prefix, box->box)) {
|
||||
if (imap_create) {
|
||||
if (imap_flags & IMAP_CREATE) {
|
||||
if (imap_exec (imap, "CREATE \"%s%s\"", imap->prefix, box->box))
|
||||
goto bail;
|
||||
if (imap_exec (imap, "SELECT \"%s%s\"", imap->prefix, box->box))
|
||||
|
@ -940,7 +940,8 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap, int imap_create)
|
|||
imap->minuid = minuid;
|
||||
if (imap->count > 0)
|
||||
{
|
||||
if (imap_exec (imap, "UID FETCH %d:* (FLAGS RFC822.SIZE)", minuid))
|
||||
if (imap_exec (imap, "UID FETCH %d:* (FLAGS%s)", minuid,
|
||||
(imap_flags & IMAP_GET_SIZE) ? " RFC822.SIZE" : ""))
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,11 @@ imap_t;
|
|||
#define OPEN_FAST (1<<0) /* fast open - don't parse */
|
||||
#define OPEN_CREATE (1<<1) /* create mailbox if nonexistent */
|
||||
|
||||
/* flags for imap_open */
|
||||
#define IMAP_CREATE (1<<0) /* Create remote mailboxes if necessary */
|
||||
#define IMAP_GET_SIZE (1<<1) /* Request the RFC 822 SIZE */
|
||||
|
||||
|
||||
extern config_t global;
|
||||
extern config_t *boxes;
|
||||
extern unsigned int Tag;
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -197,7 +197,7 @@ main (int argc, char **argv)
|
|||
int list = 0;
|
||||
int o2o = 0;
|
||||
int mbox_open_mode = 0;
|
||||
int imap_create = 0;
|
||||
int imap_flags = 0;
|
||||
|
||||
pw = getpwuid (getuid ());
|
||||
|
||||
|
@ -240,13 +240,13 @@ main (int argc, char **argv)
|
|||
break;
|
||||
case 'C':
|
||||
mbox_open_mode |= OPEN_CREATE;
|
||||
imap_create = 1;
|
||||
imap_flags |= IMAP_CREATE;
|
||||
break;
|
||||
case 'L':
|
||||
mbox_open_mode |= OPEN_CREATE;
|
||||
break;
|
||||
case 'R':
|
||||
imap_create = 1;
|
||||
imap_flags |= IMAP_CREATE;
|
||||
break;
|
||||
case 'c':
|
||||
config = optarg;
|
||||
|
@ -403,7 +403,9 @@ main (int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
|
||||
imap = imap_open (box, fast ? mail->maxuid + 1 : 1, imap, imap_create);
|
||||
if (box->max_size)
|
||||
imap_flags |= IMAP_GET_SIZE;
|
||||
imap = imap_open (box, fast ? mail->maxuid + 1 : 1, imap, imap_flags);
|
||||
if (!imap)
|
||||
{
|
||||
fprintf (stderr, "%s: skipping mailbox due to IMAP error\n",
|
||||
|
|
Loading…
Reference in New Issue
Block a user