Fix _atomic_write
This commit is contained in:
parent
5e5b8b844f
commit
5c2075cb6c
@ -392,8 +392,9 @@ class Collection(BaseCollection):
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def _atomic_write(self, path, mode="w"):
|
def _atomic_write(self, path, mode="w"):
|
||||||
|
directory = os.path.dirname(path)
|
||||||
tmp = NamedTemporaryFile(
|
tmp = NamedTemporaryFile(
|
||||||
mode=mode, dir=os.path.dirname(path), encoding=self.encoding,
|
mode=mode, dir=directory, encoding=self.encoding,
|
||||||
delete=False, prefix=".Radicale.tmp-")
|
delete=False, prefix=".Radicale.tmp-")
|
||||||
try:
|
try:
|
||||||
yield tmp
|
yield tmp
|
||||||
@ -408,7 +409,7 @@ class Collection(BaseCollection):
|
|||||||
tmp.close()
|
tmp.close()
|
||||||
os.remove(tmp.name)
|
os.remove(tmp.name)
|
||||||
raise
|
raise
|
||||||
self._sync_directory(dir)
|
self._sync_directory(directory)
|
||||||
|
|
||||||
def _find_available_file_name(self):
|
def _find_available_file_name(self):
|
||||||
# Prevent infinite loop
|
# Prevent infinite loop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user