True 1-way sync (backup)
This commit enables true 1-way syncing between repositories. This has often been demanded for backup purposes when you do not want to cause accidental modifications of your backup that would be propagated to the other side. This has been implemented by allowing to configure a Repository as 'readonly' to forbid any modification on it. 'readonly' applies to all the type of repositories. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
3d4dc11a8b
commit
f3249e0856
@ -13,6 +13,11 @@ others.
|
|||||||
New Features
|
New Features
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
* Enable 1-way synchronization by settting a [Repository ...] to
|
||||||
|
readonly = True. When e.g. using offlineimap for backup purposes you
|
||||||
|
can thus make sure that no changes in your backup trickle back into
|
||||||
|
the main IMAP server.
|
||||||
|
|
||||||
Changes
|
Changes
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# Sample configuration file
|
# Sample configuration file
|
||||||
# Copyright (C) 2002-2005 John Goerzen
|
# Copyright (C) 2002-2011 John Goerzen & contributors
|
||||||
# <jgoerzen@complete.org>
|
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -67,13 +66,14 @@ maxsyncaccounts = 1
|
|||||||
|
|
||||||
ui = Blinkenlights
|
ui = Blinkenlights
|
||||||
|
|
||||||
# If you try to synchronize messages to a read-only folder,
|
# If you try to synchronize messages to a folder which the IMAP server
|
||||||
# OfflineIMAP will generate a warning. If you want to suppress these
|
# considers read-only, OfflineIMAP will generate a warning. If you want
|
||||||
# warnings, set ignore-readonly to yes. Read-only IMAP folders allow
|
# to suppress these warnings, set ignore-readonly to yes. Read-only
|
||||||
# reading but not modification, so if you try to change messages in
|
# IMAP folders allow reading but not modification, so if you try to
|
||||||
# the local copy of such a folder, the IMAP server will prevent
|
# change messages in the local copy of such a folder, the IMAP server
|
||||||
# OfflineIMAP from propagating those changes to the IMAP server.
|
# will prevent OfflineIMAP from propagating those changes to the IMAP
|
||||||
|
# server. Note that ignore-readonly is unrelated to the "readonly"
|
||||||
|
# setting which prevents a repository from being modified at all.
|
||||||
ignore-readonly = no
|
ignore-readonly = no
|
||||||
|
|
||||||
########## Advanced settings
|
########## Advanced settings
|
||||||
@ -469,6 +469,11 @@ subscribedonly = no
|
|||||||
#
|
#
|
||||||
# foldersort = lambda x, y: -cmp(x, y)
|
# foldersort = lambda x, y: -cmp(x, y)
|
||||||
|
|
||||||
|
# Enable 1-way synchronization. When setting 'readonly' to True, this
|
||||||
|
# repository will not be modified during synchronization. Use to
|
||||||
|
# e.g. backup an IMAP server. The readonly setting can be applied to any
|
||||||
|
# type of Repository (Maildir, Imap, etc).
|
||||||
|
readonly = False
|
||||||
|
|
||||||
[Repository GmailExample]
|
[Repository GmailExample]
|
||||||
|
|
||||||
@ -509,3 +514,5 @@ realdelete = no
|
|||||||
#
|
#
|
||||||
# spamfolder = [Google Mail]/Spam
|
# spamfolder = [Google Mail]/Spam
|
||||||
|
|
||||||
|
# Enable 1-way synchronization. See above for explanation.
|
||||||
|
readonly = False
|
||||||
|
@ -260,6 +260,8 @@ class SyncableAccount(Account):
|
|||||||
remoterepos = self.remoterepos
|
remoterepos = self.remoterepos
|
||||||
localrepos = self.localrepos
|
localrepos = self.localrepos
|
||||||
statusrepos = self.statusrepos
|
statusrepos = self.statusrepos
|
||||||
|
# replicate the folderstructure from REMOTE to LOCAL
|
||||||
|
if not localrepos.getconf('readonly', False):
|
||||||
self.ui.syncfolders(remoterepos, localrepos)
|
self.ui.syncfolders(remoterepos, localrepos)
|
||||||
remoterepos.syncfoldersto(localrepos, [statusrepos])
|
remoterepos.syncfoldersto(localrepos, [statusrepos])
|
||||||
|
|
||||||
@ -374,12 +376,20 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
|||||||
remotefolder.getmessagecount())
|
remotefolder.getmessagecount())
|
||||||
|
|
||||||
# Synchronize remote changes.
|
# Synchronize remote changes.
|
||||||
|
if not localrepos.getconf('readonly', False):
|
||||||
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
|
||||||
remotefolder.syncmessagesto(localfolder, statusfolder)
|
remotefolder.syncmessagesto(localfolder, statusfolder)
|
||||||
|
else:
|
||||||
|
ui.debug('imap', "Not syncing to read-only repository '%s'" \
|
||||||
|
% localrepos.getname())
|
||||||
|
|
||||||
# Synchronize local changes
|
# Synchronize local changes
|
||||||
|
if not remoterepos.getconf('readonly', False):
|
||||||
ui.syncingmessages(localrepos, localfolder, remoterepos, remotefolder)
|
ui.syncingmessages(localrepos, localfolder, remoterepos, remotefolder)
|
||||||
localfolder.syncmessagesto(remotefolder, statusfolder)
|
localfolder.syncmessagesto(remotefolder, statusfolder)
|
||||||
|
else:
|
||||||
|
ui.debug('', "Not syncing to read-only repository '%s'" \
|
||||||
|
% remoterepos.getname())
|
||||||
|
|
||||||
statusfolder.save()
|
statusfolder.save()
|
||||||
localrepos.restore_atime()
|
localrepos.restore_atime()
|
||||||
|
Loading…
Reference in New Issue
Block a user