2003-01-04 05:57:46 +01:00
|
|
|
# Copyright (C) 2003 John Goerzen
|
|
|
|
# <jgoerzen@complete.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2003-04-16 21:23:45 +02:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
2003-01-04 05:57:46 +01:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2006-08-12 06:15:55 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-01-04 05:57:46 +01:00
|
|
|
|
2003-07-25 03:58:20 +02:00
|
|
|
from offlineimap import threadutil, mbnames, CustomConfig
|
|
|
|
import offlineimap.repository.Base, offlineimap.repository.LocalStatus
|
2003-01-04 05:57:46 +01:00
|
|
|
from offlineimap.ui import UIBase
|
|
|
|
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
|
|
|
|
from threading import Event
|
|
|
|
import os
|
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
def getaccountlist(customconfig):
|
|
|
|
return customconfig.getsectionlist('Account')
|
|
|
|
|
|
|
|
def AccountListGenerator(customconfig):
|
|
|
|
return [Account(customconfig, accountname)
|
|
|
|
for accountname in getaccountlist(customconfig)]
|
|
|
|
|
|
|
|
def AccountHashGenerator(customconfig):
|
|
|
|
retval = {}
|
|
|
|
for item in AccountListGenerator(customconfig):
|
|
|
|
retval[item.getname()] = item
|
|
|
|
return retval
|
|
|
|
|
2003-01-04 05:57:46 +01:00
|
|
|
mailboxes = []
|
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
class Account(CustomConfig.ConfigHelperMixin):
|
2003-01-04 05:57:46 +01:00
|
|
|
def __init__(self, config, name):
|
|
|
|
self.config = config
|
|
|
|
self.name = name
|
|
|
|
self.metadatadir = config.getmetadatadir()
|
|
|
|
self.localeval = config.getlocaleval()
|
|
|
|
self.ui = UIBase.getglobalui()
|
2003-04-29 04:25:42 +02:00
|
|
|
self.refreshperiod = self.getconffloat('autorefresh', 0.0)
|
Daniel Jacobowitz patches
fixes deb#433732
Date: Sun, 30 Sep 2007 13:54:56 -0400
From: Daniel Jacobowitz <drow@false.org>
To: offlineimap@complete.org
Subject: Assorted patches
Here's the result of a lazy Sunday hacking on offlineimap. Sorry for
not breaking this into multiple patches. They're mostly logically
independent so just ask if that would make a difference.
First, a new -q (quick) option. The quick option means to only update
folders that seem to have had significant changes. For Maildir, any
change to any message UID or flags is significant, because checking
the flags doesn't add a significant cost. For IMAP, only a change to
the total number of messages or a change in the UID of the most recent
message is significant. This should catch everything except for
flags changes.
The difference in bandwidth is astonishing: a quick sync takes 80K
instead of 5.3MB, and 28 seconds instead of 90.
There's a configuration variable that lets you say every tenth sync
should update flags, but let all the intervening ones be lighter.
Second, a fix to the UID validity problems many people have been
reporting with Courier. As discussed in Debian bug #433732, I changed
the UID validity check to use SELECT unless the server complains that
the folder is read-only. This avoids the Courier bug (see the Debian
log for more details). This won't fix existing validity errors, you
need to remove the local status and validity files by hand and resync.
Third, some speedups in Maildir checking. It's still pretty slow
due to a combination of poor performance in os.listdir (never reads
more than 4K of directory entries at a time) and some semaphore that
leads to lots of futex wake operations, but at least this saves
20% or so of the CPU time running offlineimap on a single folder:
Time with quick refresh and md5 in loop: 4.75s user 0.46s system 12%
cpu 41.751 total
Time with quick refresh and md5 out of loop: 4.38s user 0.50s system
14% cpu 34.799 total
Time using string compare to check folder: 4.11s user 0.47s system 13%
cpu 34.788 total
And fourth, some display fixes for Curses.Blinkenlights. I made
warnings more visible, made the new quick sync message cyan, and
made all not explicitly colored messages grey. That last one was
really bugging me. Any time OfflineIMAP printed a warning in
this UI, it had even odds of coming out black on black!
Anyway, I hope these are useful. I'm happy to revise them if you see
a problem.
--
Daniel Jacobowitz
CodeSourcery
2007-10-01 23:20:37 +02:00
|
|
|
self.quicknum = 0
|
2003-04-29 04:25:42 +02:00
|
|
|
if self.refreshperiod == 0.0:
|
2003-01-04 05:57:46 +01:00
|
|
|
self.refreshperiod = None
|
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
def getlocaleval(self):
|
|
|
|
return self.localeval
|
|
|
|
|
|
|
|
def getconfig(self):
|
|
|
|
return self.config
|
|
|
|
|
|
|
|
def getname(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def getsection(self):
|
|
|
|
return 'Account ' + self.getname()
|
2003-01-04 05:57:46 +01:00
|
|
|
|
|
|
|
def sleeper(self):
|
|
|
|
"""Sleep handler. Returns same value as UIBase.sleep:
|
|
|
|
0 if timeout expired, 1 if there was a request to cancel the timer,
|
|
|
|
and 2 if there is a request to abort the program.
|
|
|
|
|
|
|
|
Also, returns 100 if configured to not sleep at all."""
|
|
|
|
|
|
|
|
if not self.refreshperiod:
|
|
|
|
return 100
|
2003-04-18 04:18:34 +02:00
|
|
|
|
|
|
|
kaobjs = []
|
|
|
|
|
|
|
|
if hasattr(self, 'localrepos'):
|
|
|
|
kaobjs.append(self.localrepos)
|
|
|
|
if hasattr(self, 'remoterepos'):
|
|
|
|
kaobjs.append(self.remoterepos)
|
|
|
|
|
|
|
|
for item in kaobjs:
|
|
|
|
item.startkeepalive()
|
|
|
|
|
2003-04-29 04:25:42 +02:00
|
|
|
refreshperiod = int(self.refreshperiod * 60)
|
2003-01-04 05:57:46 +01:00
|
|
|
sleepresult = self.ui.sleep(refreshperiod)
|
|
|
|
if sleepresult == 2:
|
|
|
|
# Cancel keep-alive, but don't bother terminating threads
|
2003-04-18 04:18:34 +02:00
|
|
|
for item in kaobjs:
|
|
|
|
item.stopkeepalive(abrupt = 1)
|
2003-01-04 05:57:46 +01:00
|
|
|
return sleepresult
|
|
|
|
else:
|
|
|
|
# Cancel keep-alive and wait for thread to terminate.
|
2003-04-18 04:18:34 +02:00
|
|
|
for item in kaobjs:
|
|
|
|
item.stopkeepalive(abrupt = 0)
|
2003-01-04 05:57:46 +01:00
|
|
|
return sleepresult
|
|
|
|
|
|
|
|
class AccountSynchronizationMixin:
|
|
|
|
def syncrunner(self):
|
2003-01-06 00:07:58 +01:00
|
|
|
self.ui.registerthread(self.name)
|
2003-01-04 05:57:46 +01:00
|
|
|
self.ui.acct(self.name)
|
2003-04-18 04:18:34 +02:00
|
|
|
accountmetadata = self.getaccountmeta()
|
|
|
|
if not os.path.exists(accountmetadata):
|
|
|
|
os.mkdir(accountmetadata, 0700)
|
|
|
|
|
2003-07-25 03:58:20 +02:00
|
|
|
self.remoterepos = offlineimap.repository.Base.LoadRepository(self.getconf('remoterepository'), self, 'remote')
|
2003-04-18 04:18:34 +02:00
|
|
|
|
|
|
|
# Connect to the local repository.
|
2003-07-25 03:58:20 +02:00
|
|
|
self.localrepos = offlineimap.repository.Base.LoadRepository(self.getconf('localrepository'), self, 'local')
|
2003-04-18 04:18:34 +02:00
|
|
|
|
|
|
|
# Connect to the local cache.
|
2003-07-25 03:58:20 +02:00
|
|
|
self.statusrepos = offlineimap.repository.LocalStatus.LocalStatusRepository(self.getconf('localrepository'), self)
|
2003-04-18 04:18:34 +02:00
|
|
|
|
2003-01-04 05:57:46 +01:00
|
|
|
if not self.refreshperiod:
|
|
|
|
self.sync()
|
|
|
|
self.ui.acctdone(self.name)
|
|
|
|
return
|
|
|
|
looping = 1
|
|
|
|
while looping:
|
|
|
|
self.sync()
|
|
|
|
looping = self.sleeper() != 2
|
|
|
|
self.ui.acctdone(self.name)
|
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
def getaccountmeta(self):
|
|
|
|
return os.path.join(self.metadatadir, 'Account-' + self.name)
|
|
|
|
|
2003-01-04 05:57:46 +01:00
|
|
|
def sync(self):
|
|
|
|
# We don't need an account lock because syncitall() goes through
|
|
|
|
# each account once, then waits for all to finish.
|
Daniel Jacobowitz patches
fixes deb#433732
Date: Sun, 30 Sep 2007 13:54:56 -0400
From: Daniel Jacobowitz <drow@false.org>
To: offlineimap@complete.org
Subject: Assorted patches
Here's the result of a lazy Sunday hacking on offlineimap. Sorry for
not breaking this into multiple patches. They're mostly logically
independent so just ask if that would make a difference.
First, a new -q (quick) option. The quick option means to only update
folders that seem to have had significant changes. For Maildir, any
change to any message UID or flags is significant, because checking
the flags doesn't add a significant cost. For IMAP, only a change to
the total number of messages or a change in the UID of the most recent
message is significant. This should catch everything except for
flags changes.
The difference in bandwidth is astonishing: a quick sync takes 80K
instead of 5.3MB, and 28 seconds instead of 90.
There's a configuration variable that lets you say every tenth sync
should update flags, but let all the intervening ones be lighter.
Second, a fix to the UID validity problems many people have been
reporting with Courier. As discussed in Debian bug #433732, I changed
the UID validity check to use SELECT unless the server complains that
the folder is read-only. This avoids the Courier bug (see the Debian
log for more details). This won't fix existing validity errors, you
need to remove the local status and validity files by hand and resync.
Third, some speedups in Maildir checking. It's still pretty slow
due to a combination of poor performance in os.listdir (never reads
more than 4K of directory entries at a time) and some semaphore that
leads to lots of futex wake operations, but at least this saves
20% or so of the CPU time running offlineimap on a single folder:
Time with quick refresh and md5 in loop: 4.75s user 0.46s system 12%
cpu 41.751 total
Time with quick refresh and md5 out of loop: 4.38s user 0.50s system
14% cpu 34.799 total
Time using string compare to check folder: 4.11s user 0.47s system 13%
cpu 34.788 total
And fourth, some display fixes for Curses.Blinkenlights. I made
warnings more visible, made the new quick sync message cyan, and
made all not explicitly colored messages grey. That last one was
really bugging me. Any time OfflineIMAP printed a warning in
this UI, it had even odds of coming out black on black!
Anyway, I hope these are useful. I'm happy to revise them if you see
a problem.
--
Daniel Jacobowitz
CodeSourcery
2007-10-01 23:20:37 +02:00
|
|
|
|
|
|
|
quickconfig = self.getconfint('quick', 0)
|
|
|
|
if quickconfig < 0:
|
|
|
|
quick = True
|
|
|
|
elif quickconfig > 0:
|
|
|
|
if self.quicknum == 0 or self.quicknum > quickconfig:
|
|
|
|
self.quicknum = 1
|
|
|
|
quick = False
|
|
|
|
else:
|
|
|
|
self.quicknum = self.quicknum + 1
|
|
|
|
quick = True
|
|
|
|
else:
|
|
|
|
quick = False
|
|
|
|
|
2003-01-04 05:57:46 +01:00
|
|
|
try:
|
2003-04-18 04:18:34 +02:00
|
|
|
remoterepos = self.remoterepos
|
|
|
|
localrepos = self.localrepos
|
|
|
|
statusrepos = self.statusrepos
|
2003-01-04 05:57:46 +01:00
|
|
|
self.ui.syncfolders(remoterepos, localrepos)
|
2007-09-02 02:43:15 +02:00
|
|
|
|
|
|
|
(remoteignored,remotenew) = remoterepos.syncfoldersto(localrepos,statusrepos)
|
|
|
|
if len(remotenew):
|
|
|
|
localrepos.forgetfolders()
|
|
|
|
|
|
|
|
(localignored,localnew) = localrepos.syncfoldersto(remoterepos,statusrepos)
|
|
|
|
if len(localnew):
|
|
|
|
remoterepos.forgetfolders()
|
2003-01-04 05:57:46 +01:00
|
|
|
|
|
|
|
folderthreads = []
|
|
|
|
for remotefolder in remoterepos.getfolders():
|
2007-09-02 02:43:15 +02:00
|
|
|
if remotefolder.getvisiblename() in remoteignored:
|
|
|
|
continue
|
2003-01-04 05:57:46 +01:00
|
|
|
thread = InstanceLimitedThread(\
|
2003-04-18 04:18:34 +02:00
|
|
|
instancename = 'FOLDER_' + self.remoterepos.getname(),
|
2003-01-04 05:57:46 +01:00
|
|
|
target = syncfolder,
|
|
|
|
name = "Folder sync %s[%s]" % \
|
|
|
|
(self.name, remotefolder.getvisiblename()),
|
|
|
|
args = (self.name, remoterepos, remotefolder, localrepos,
|
Daniel Jacobowitz patches
fixes deb#433732
Date: Sun, 30 Sep 2007 13:54:56 -0400
From: Daniel Jacobowitz <drow@false.org>
To: offlineimap@complete.org
Subject: Assorted patches
Here's the result of a lazy Sunday hacking on offlineimap. Sorry for
not breaking this into multiple patches. They're mostly logically
independent so just ask if that would make a difference.
First, a new -q (quick) option. The quick option means to only update
folders that seem to have had significant changes. For Maildir, any
change to any message UID or flags is significant, because checking
the flags doesn't add a significant cost. For IMAP, only a change to
the total number of messages or a change in the UID of the most recent
message is significant. This should catch everything except for
flags changes.
The difference in bandwidth is astonishing: a quick sync takes 80K
instead of 5.3MB, and 28 seconds instead of 90.
There's a configuration variable that lets you say every tenth sync
should update flags, but let all the intervening ones be lighter.
Second, a fix to the UID validity problems many people have been
reporting with Courier. As discussed in Debian bug #433732, I changed
the UID validity check to use SELECT unless the server complains that
the folder is read-only. This avoids the Courier bug (see the Debian
log for more details). This won't fix existing validity errors, you
need to remove the local status and validity files by hand and resync.
Third, some speedups in Maildir checking. It's still pretty slow
due to a combination of poor performance in os.listdir (never reads
more than 4K of directory entries at a time) and some semaphore that
leads to lots of futex wake operations, but at least this saves
20% or so of the CPU time running offlineimap on a single folder:
Time with quick refresh and md5 in loop: 4.75s user 0.46s system 12%
cpu 41.751 total
Time with quick refresh and md5 out of loop: 4.38s user 0.50s system
14% cpu 34.799 total
Time using string compare to check folder: 4.11s user 0.47s system 13%
cpu 34.788 total
And fourth, some display fixes for Curses.Blinkenlights. I made
warnings more visible, made the new quick sync message cyan, and
made all not explicitly colored messages grey. That last one was
really bugging me. Any time OfflineIMAP printed a warning in
this UI, it had even odds of coming out black on black!
Anyway, I hope these are useful. I'm happy to revise them if you see
a problem.
--
Daniel Jacobowitz
CodeSourcery
2007-10-01 23:20:37 +02:00
|
|
|
statusrepos, quick))
|
2003-01-04 05:57:46 +01:00
|
|
|
thread.setDaemon(1)
|
|
|
|
thread.start()
|
|
|
|
folderthreads.append(thread)
|
|
|
|
threadutil.threadsreset(folderthreads)
|
2003-01-06 21:40:23 +01:00
|
|
|
mbnames.write()
|
2007-07-06 18:46:29 +02:00
|
|
|
localrepos.forgetfolders()
|
|
|
|
remoterepos.forgetfolders()
|
2003-04-18 04:18:34 +02:00
|
|
|
localrepos.holdordropconnections()
|
|
|
|
remoterepos.holdordropconnections()
|
2003-01-04 05:57:46 +01:00
|
|
|
finally:
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SyncableAccount(Account, AccountSynchronizationMixin):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
Daniel Jacobowitz patches
fixes deb#433732
Date: Sun, 30 Sep 2007 13:54:56 -0400
From: Daniel Jacobowitz <drow@false.org>
To: offlineimap@complete.org
Subject: Assorted patches
Here's the result of a lazy Sunday hacking on offlineimap. Sorry for
not breaking this into multiple patches. They're mostly logically
independent so just ask if that would make a difference.
First, a new -q (quick) option. The quick option means to only update
folders that seem to have had significant changes. For Maildir, any
change to any message UID or flags is significant, because checking
the flags doesn't add a significant cost. For IMAP, only a change to
the total number of messages or a change in the UID of the most recent
message is significant. This should catch everything except for
flags changes.
The difference in bandwidth is astonishing: a quick sync takes 80K
instead of 5.3MB, and 28 seconds instead of 90.
There's a configuration variable that lets you say every tenth sync
should update flags, but let all the intervening ones be lighter.
Second, a fix to the UID validity problems many people have been
reporting with Courier. As discussed in Debian bug #433732, I changed
the UID validity check to use SELECT unless the server complains that
the folder is read-only. This avoids the Courier bug (see the Debian
log for more details). This won't fix existing validity errors, you
need to remove the local status and validity files by hand and resync.
Third, some speedups in Maildir checking. It's still pretty slow
due to a combination of poor performance in os.listdir (never reads
more than 4K of directory entries at a time) and some semaphore that
leads to lots of futex wake operations, but at least this saves
20% or so of the CPU time running offlineimap on a single folder:
Time with quick refresh and md5 in loop: 4.75s user 0.46s system 12%
cpu 41.751 total
Time with quick refresh and md5 out of loop: 4.38s user 0.50s system
14% cpu 34.799 total
Time using string compare to check folder: 4.11s user 0.47s system 13%
cpu 34.788 total
And fourth, some display fixes for Curses.Blinkenlights. I made
warnings more visible, made the new quick sync message cyan, and
made all not explicitly colored messages grey. That last one was
really bugging me. Any time OfflineIMAP printed a warning in
this UI, it had even odds of coming out black on black!
Anyway, I hope these are useful. I'm happy to revise them if you see
a problem.
--
Daniel Jacobowitz
CodeSourcery
2007-10-01 23:20:37 +02:00
|
|
|
statusrepos, quick):
|
2003-01-04 05:57:46 +01:00
|
|
|
global mailboxes
|
|
|
|
ui = UIBase.getglobalui()
|
2003-01-06 00:07:58 +01:00
|
|
|
ui.registerthread(accountname)
|
2003-01-04 05:57:46 +01:00
|
|
|
# Load local folder.
|
|
|
|
localfolder = localrepos.\
|
|
|
|
getfolder(remotefolder.getvisiblename().\
|
|
|
|
replace(remoterepos.getsep(), localrepos.getsep()))
|
|
|
|
# Write the mailboxes
|
2003-01-06 21:40:23 +01:00
|
|
|
mbnames.add(accountname, localfolder.getvisiblename())
|
2003-01-04 05:57:46 +01:00
|
|
|
|
|
|
|
# Load status folder.
|
|
|
|
statusfolder = statusrepos.getfolder(remotefolder.getvisiblename().\
|
|
|
|
replace(remoterepos.getsep(),
|
|
|
|
statusrepos.getsep()))
|
|
|
|
if localfolder.getuidvalidity() == None:
|
|
|
|
# This is a new folder, so delete the status cache to be sure
|
|
|
|
# we don't have a conflict.
|
|
|
|
statusfolder.deletemessagelist()
|
|
|
|
|
|
|
|
statusfolder.cachemessagelist()
|
|
|
|
|
Daniel Jacobowitz patches
fixes deb#433732
Date: Sun, 30 Sep 2007 13:54:56 -0400
From: Daniel Jacobowitz <drow@false.org>
To: offlineimap@complete.org
Subject: Assorted patches
Here's the result of a lazy Sunday hacking on offlineimap. Sorry for
not breaking this into multiple patches. They're mostly logically
independent so just ask if that would make a difference.
First, a new -q (quick) option. The quick option means to only update
folders that seem to have had significant changes. For Maildir, any
change to any message UID or flags is significant, because checking
the flags doesn't add a significant cost. For IMAP, only a change to
the total number of messages or a change in the UID of the most recent
message is significant. This should catch everything except for
flags changes.
The difference in bandwidth is astonishing: a quick sync takes 80K
instead of 5.3MB, and 28 seconds instead of 90.
There's a configuration variable that lets you say every tenth sync
should update flags, but let all the intervening ones be lighter.
Second, a fix to the UID validity problems many people have been
reporting with Courier. As discussed in Debian bug #433732, I changed
the UID validity check to use SELECT unless the server complains that
the folder is read-only. This avoids the Courier bug (see the Debian
log for more details). This won't fix existing validity errors, you
need to remove the local status and validity files by hand and resync.
Third, some speedups in Maildir checking. It's still pretty slow
due to a combination of poor performance in os.listdir (never reads
more than 4K of directory entries at a time) and some semaphore that
leads to lots of futex wake operations, but at least this saves
20% or so of the CPU time running offlineimap on a single folder:
Time with quick refresh and md5 in loop: 4.75s user 0.46s system 12%
cpu 41.751 total
Time with quick refresh and md5 out of loop: 4.38s user 0.50s system
14% cpu 34.799 total
Time using string compare to check folder: 4.11s user 0.47s system 13%
cpu 34.788 total
And fourth, some display fixes for Curses.Blinkenlights. I made
warnings more visible, made the new quick sync message cyan, and
made all not explicitly colored messages grey. That last one was
really bugging me. Any time OfflineIMAP printed a warning in
this UI, it had even odds of coming out black on black!
Anyway, I hope these are useful. I'm happy to revise them if you see
a problem.
--
Daniel Jacobowitz
CodeSourcery
2007-10-01 23:20:37 +02:00
|
|
|
if quick:
|
|
|
|
if not localfolder.quickchanged(statusfolder) \
|
|
|
|
and not remotefolder.quickchanged(statusfolder):
|
|
|
|
ui.skippingfolder(remotefolder)
|
|
|
|
localrepos.restore_atime()
|
|
|
|
return
|
|
|
|
|
|
|
|
# Load local folder
|
|
|
|
ui.syncingfolder(remoterepos, remotefolder, localrepos, localfolder)
|
|
|
|
ui.loadmessagelist(localrepos, localfolder)
|
|
|
|
localfolder.cachemessagelist()
|
|
|
|
ui.messagelistloaded(localrepos, localfolder, len(localfolder.getmessagelist().keys()))
|
|
|
|
|
2003-04-18 04:18:34 +02:00
|
|
|
# If either the local or the status folder has messages and there is a UID
|
|
|
|
# validity problem, warn and abort. If there are no messages, UW IMAPd
|
|
|
|
# loses UIDVALIDITY. But we don't really need it if both local folders are
|
|
|
|
# empty. So, in that case, just save it off.
|
|
|
|
if len(localfolder.getmessagelist()) or len(statusfolder.getmessagelist()):
|
|
|
|
if not localfolder.isuidvalidityok():
|
2007-03-15 05:39:15 +01:00
|
|
|
ui.validityproblem(localfolder)
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
localrepos.restore_atime()
|
2003-04-18 04:18:34 +02:00
|
|
|
return
|
|
|
|
if not remotefolder.isuidvalidityok():
|
2007-03-15 05:39:15 +01:00
|
|
|
ui.validityproblem(remotefolder)
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
localrepos.restore_atime()
|
2003-04-18 04:18:34 +02:00
|
|
|
return
|
2003-01-04 05:57:46 +01:00
|
|
|
else:
|
2003-04-18 04:18:34 +02:00
|
|
|
localfolder.saveuidvalidity()
|
|
|
|
remotefolder.saveuidvalidity()
|
2003-01-04 05:57:46 +01:00
|
|
|
|
|
|
|
# Load remote folder.
|
|
|
|
ui.loadmessagelist(remoterepos, remotefolder)
|
|
|
|
remotefolder.cachemessagelist()
|
|
|
|
ui.messagelistloaded(remoterepos, remotefolder,
|
|
|
|
len(remotefolder.getmessagelist().keys()))
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
2007-09-02 02:43:15 +02:00
|
|
|
if ((statusfolder.isnewfolder()) and
|
|
|
|
(len(localfolder.getmessagelist()) > 0) and
|
|
|
|
(len(remotefolder.getmessagelist()) == 0)):
|
|
|
|
# This is a locally created folder. Copy its contents to the
|
|
|
|
# remote folder, and to the StatusFolder.
|
|
|
|
|
|
|
|
localfolder.syncmessagesto(statusfolder, [remotefolder, statusfolder])
|
|
|
|
|
2003-01-04 05:57:46 +01:00
|
|
|
if not statusfolder.isnewfolder():
|
|
|
|
# Delete local copies of remote messages. This way,
|
|
|
|
# if a message's flag is modified locally but it has been
|
|
|
|
# deleted remotely, we'll delete it locally. Otherwise, we
|
|
|
|
# try to modify a deleted message's flags! This step
|
|
|
|
# need only be taken if a statusfolder is present; otherwise,
|
|
|
|
# there is no action taken *to* the remote repository.
|
|
|
|
|
|
|
|
remotefolder.syncmessagesto_delete(localfolder, [localfolder,
|
|
|
|
statusfolder])
|
|
|
|
ui.syncingmessages(localrepos, localfolder, remoterepos, remotefolder)
|
|
|
|
localfolder.syncmessagesto(statusfolder, [remotefolder, statusfolder])
|
|
|
|
|
|
|
|
# Synchronize remote changes.
|
|
|
|
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
2003-01-06 05:54:59 +01:00
|
|
|
remotefolder.syncmessagesto(localfolder, [localfolder, statusfolder])
|
2003-01-04 05:57:46 +01:00
|
|
|
|
|
|
|
# Make sure the status folder is up-to-date.
|
|
|
|
ui.syncingmessages(localrepos, localfolder, statusrepos, statusfolder)
|
|
|
|
localfolder.syncmessagesto(statusfolder)
|
|
|
|
statusfolder.save()
|
New restoreatime patch from Ben Kibbey
From: Ben Kibbey
Subject: Re: Removed restoratime from OfflineIMAP
On Wed, May 03, 2006 at 10:08:35PM -0500, John Goerzen wrote:
> Hi Ben,
>
> Thanks for your restoreatime patch.
>
> However, I have received this bug report:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365933
>
> After looking at the problem, here's what's going on.
>
> The person is using IMAP as the local repository as well.
>
> You really need to move the atime save and restore code from accounts.py
> into the repository/Maildir.py. Then, for any new call you add to the
> Maildir repository (that will be called from outside Maildir.py), you
> need to add a corresponding default function to repository/Base.py, and
> also make sure that on folders (such as IMAP) where atime restoration
> makes no sense, no error is generated.
>
> Let me know if that doesn't make sense to you. If you get it fixed, I'd
> be happy to re-apply it to a future version of OfflineIMAP.
>
> -- John Goerzen
>
Attached is a new diff that should work though not really tested
(v4.0.14). In repository/Base.py restore_atime() will call
self.restore_folder_atimes() only if the folder type is Maildir. Let me
know if it has any more problems.
2006-09-06 03:33:07 +02:00
|
|
|
localrepos.restore_atime()
|
2003-01-04 05:57:46 +01:00
|
|
|
|