+offlineimap (3.99.9) unstable; urgency=low
+
+ * Added check to make sure that two processes do not run in the same
+ directory at once.
+
+ -- John Goerzen <jgoerzen@complete.org> Wed, 29 Jan 2003 13:19:14 -0600
+
offlineimap (3.99.8) unstable; urgency=low
* This is a 4.0 TRACK release, and may be unstable or in flux!
from offlineimap.localeval import LocalEval
from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
from offlineimap.ui import UIBase
-import re, os, os.path, offlineimap, sys
+import re, os, os.path, offlineimap, sys, fcntl
from offlineimap.CustomConfig import CustomConfigParser
from threading import *
from getopt import getopt
+lockfd = None
+
+def lock(config, ui):
+ global lockfd
+ lockfd = open(config.getmetadatadir() + "/lock", "w")
+ try:
+ fcntl.flock(lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError:
+ ui.locked()
+ ui.terminate(1)
+
def startup(versionno):
assert versionno == version.versionstr, "Revision of main program (%d) does not match that of library (%d). Please double-check your PYTHONPATH and installation locations." % (revno, version.revno)
options = {}
for section in config.getaccountlist():
config.remove_option(section, "autorefresh")
+ lock(config, ui)
+
accounts = config.get("general", "accounts")
if '-a' in options:
accounts = options['-a']
def invaliddebug(s, debugtype):
s.warn("Invalid debug type: %s" % debugtype)
+ def locked(s):
+ s.warn("Another OfflineIMAP is running with the same metadatadir; exiting.")
+
def getnicename(s, object):
prelimname = str(object.__class__).split('.')[-1]
# Strip off extra stuff.