Cosmetics

This commit is contained in:
Guillaume Ayoub 2016-08-08 13:39:01 +02:00
parent 1e5c9f63a0
commit 5e5b8b844f

View File

@ -392,8 +392,8 @@ class Collection(BaseCollection):
@contextmanager @contextmanager
def _atomic_write(self, path, mode="w"): def _atomic_write(self, path, mode="w"):
dir = os.path.dirname(path) tmp = NamedTemporaryFile(
tmp = NamedTemporaryFile(mode=mode, dir=dir, encoding=self.encoding, mode=mode, dir=os.path.dirname(path), encoding=self.encoding,
delete=False, prefix=".Radicale.tmp-") delete=False, prefix=".Radicale.tmp-")
try: try:
yield tmp yield tmp
@ -650,10 +650,10 @@ class Collection(BaseCollection):
try: try:
os.rmdir(self._filesystem_path) os.rmdir(self._filesystem_path)
except OSError: except OSError:
with TemporaryDirectory(prefix=".Radicale.tmp-", with TemporaryDirectory(
dir=parent_dir) as tmp_dir: prefix=".Radicale.tmp-", dir=parent_dir) as tmp:
os.rename(self._filesystem_path, os.path.join( os.rename(self._filesystem_path, os.path.join(
tmp_dir, os.path.basename(self._filesystem_path))) tmp, os.path.basename(self._filesystem_path)))
self._sync_directory(parent_dir) self._sync_directory(parent_dir)
else: else:
self._sync_directory(parent_dir) self._sync_directory(parent_dir)