MaildirRepository: Beautify restore_atime code
Beauty of code is probably a subjective measure, but this patch hopefully is an improvement over the previous incarnation without changing functionality. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
ee1706fa90
commit
5bcfbc1525
@ -43,21 +43,21 @@ class MaildirRepository(BaseRepository):
|
|||||||
p = os.path.join(self.root, foldername)
|
p = os.path.join(self.root, foldername)
|
||||||
new = os.path.join(p, 'new')
|
new = os.path.join(p, 'new')
|
||||||
cur = os.path.join(p, 'cur')
|
cur = os.path.join(p, 'cur')
|
||||||
f = p, os.stat(new)[ST_ATIME], os.stat(cur)[ST_ATIME]
|
atimes = (p, os.path.getatime(new), os.path.getatime(cur))
|
||||||
self.folder_atimes.append(f)
|
self.folder_atimes.append(atimes)
|
||||||
|
|
||||||
def restore_atime(self):
|
def restore_atime(self):
|
||||||
"""Sets folders' atime back to their values after a sync
|
"""Sets folders' atime back to their values after a sync
|
||||||
|
|
||||||
Controlled by the 'restoreatime' config parameter."""
|
Controlled by the 'restoreatime' config parameter."""
|
||||||
if not self.getconfboolean('restoreatime', False):
|
if not self.getconfboolean('restoreatime', False):
|
||||||
return # not configured
|
return # not configured to restore
|
||||||
|
|
||||||
for f in self.folder_atimes:
|
for (dirpath, new_atime, cur_atime) in self.folder_atimes:
|
||||||
t = f[1], os.stat(os.path.join(f[0], 'new'))[ST_MTIME]
|
new_dir = os.path.join(dirpath, 'new')
|
||||||
os.utime(os.path.join(f[0], 'new'), t)
|
cur_dir = os.path.join(dirpath, 'cur')
|
||||||
t = f[2], os.stat(os.path.join(f[0], 'cur'))[ST_MTIME]
|
os.utime(new_dir, (new_atime, os.path.getmtime(new_dir)))
|
||||||
os.utime(os.path.join(f[0], 'cur'), t)
|
os.utime(cur_dir, (cur_atime, os.path.getmtime(cur_dir)))
|
||||||
|
|
||||||
def getlocalroot(self):
|
def getlocalroot(self):
|
||||||
return os.path.expanduser(self.getconf('localfolders'))
|
return os.path.expanduser(self.getconf('localfolders'))
|
||||||
|
Loading…
Reference in New Issue
Block a user