X-Git-Url: https://code.delx.au/offlineimap/blobdiff_plain/d6f4a8dab86754b05fa2bcb216dcb9716e111e52..cf080844ac92df72db4a85d434b73f647ec51b95:/offlineimap/repository/LocalStatus.py diff --git a/offlineimap/repository/LocalStatus.py b/offlineimap/repository/LocalStatus.py index 048026d..b3b17b1 100644 --- a/offlineimap/repository/LocalStatus.py +++ b/offlineimap/repository/LocalStatus.py @@ -19,7 +19,7 @@ from Base import BaseRepository from offlineimap import folder import offlineimap.folder.LocalStatus -import os, re +import os, re, os.path class LocalStatusRepository(BaseRepository): def __init__(self, reposname, account): @@ -38,12 +38,17 @@ class LocalStatusRepository(BaseRepository): return os.path.join(self.directory, foldername) def makefolder(self, foldername): - # "touch" the file, truncating it. + # Create parent dirs + filename = self.getfolderfilename(foldername) - file = open(filename + ".tmp", "wb") + os.makedirs(os.path.dirname(foldername), 0700) + + # "touch" the file, truncating it. + file = open(filename + ".tmp", "wt") file.write(offlineimap.folder.LocalStatus.magicline + '\n') + file.flush() + os.fsync(file.fileno()) file.close() - os.unlink(filename) os.rename(filename + ".tmp", filename) # Invalidate the cache.