MCPcopy
hub / github.com/OfflineIMAP/offlineimap / __sync

Method __sync

offlineimap/accounts.py:327–444  ·  view source on GitHub ↗

Synchronize the account once, then return. Assumes that `self.remoterepos`, `self.localrepos`, and `self.statusrepos` has already been populated, so it should only be called from the :meth:`syncrunner` function.

(self)

Source from the content-addressed store, hash-verified

325 # The syncrunner will loop on this method. This means it is called more than
326 # once during the run.
327 def __sync(self):
328 """Synchronize the account once, then return.
329
330 Assumes that `self.remoterepos`, `self.localrepos`, and
331 `self.statusrepos` has already been populated, so it should only
332 be called from the :meth:`syncrunner` function."""
333
334 folderthreads = []
335
336 hook_env = {
337 'OIMAP_ACCOUNT_NAME': self.getname(),
338 }
339
340 self.callhook('presynchook', hook_env)
341
342 if self.utf_8_support and self.remoterepos.getdecodefoldernames():
343 raise OfflineImapError("Configuration mismatch in account " +
344 "'%s'. "% self.getname() +
345 "\nAccount setting 'utf8foldernames' and repository " +
346 "setting 'decodefoldernames'\nmay not be used at the " +
347 "same time. This account has not been synchronized.\n" +
348 "Please check the configuration and documentation.",
349 OfflineImapError.ERROR.REPO)
350
351 quickconfig = self.getconfint('quick', 0)
352 if quickconfig < 0:
353 quick = True
354 elif quickconfig > 0:
355 if self.quicknum == 0 or self.quicknum > quickconfig:
356 self.quicknum = 1
357 quick = False
358 else:
359 self.quicknum = self.quicknum + 1
360 quick = True
361 else:
362 quick = False
363
364 try:
365 startedThread = False
366 remoterepos = self.remoterepos
367 localrepos = self.localrepos
368 statusrepos = self.statusrepos
369
370 # Init repos with list of folders, so we have them (and the
371 # folder delimiter etc).
372 remoterepos.getfolders()
373 localrepos.getfolders()
374
375 remoterepos.sync_folder_structure(localrepos, statusrepos)
376 # Replicate the folderstructure between REMOTE to LOCAL.
377 if not localrepos.getconfboolean('readonly', False):
378 self.ui.syncfolders(remoterepos, localrepos)
379
380 # Iterate through all folders on the remote repo and sync.
381 for remotefolder in remoterepos.getfolders():
382 # Check for CTRL-C or SIGTERM.
383 if Account.abort_NOW_signal.is_set():
384 break

Callers 1

syncrunnerMethod · 0.95

Calls 15

callhookMethod · 0.95
get_local_folderMethod · 0.95
startMethod · 0.95
OfflineImapErrorClass · 0.90
syncfolderFunction · 0.85
getdecodefoldernamesMethod · 0.80
getconfintMethod · 0.80
sync_folder_structureMethod · 0.80
getconfbooleanMethod · 0.80
getexplainednameMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected