lib.FileContext.put(): Add parameter "atomic"

Add the parameter "atomic" to put() / _put(). If instructs the implementation to take extra precautions to make sure the operation either succeeds or fails entirely, i.e. doesn't leave a broken target file behind.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-17 11:29:36 +02:00
commit 94eee5c4bb
3 changed files with 16 additions and 26 deletions

View file

@ -88,6 +88,7 @@ class FileContext(abc.ABC):
owner: str|None,
group: str|None,
mode: str|None,
atomic: bool,
) -> Result:
raise NotImplementedError()
@ -98,13 +99,14 @@ class FileContext(abc.ABC):
wd: str|None = None,
throw: bool = True,
verbose: bool|None = None,
title: str=None,
owner: str|None=None,
group: str|None=None,
mode: str|None=None,
title: str = None,
owner: str|None = None,
group: str|None = None,
mode: str|None = None,
atomic: bool = False
) -> Result:
return await self._put(content, path, wd=wd, throw=throw, verbose=verbose,
title=title, owner=owner, group=group, mode=mode)
title=title, owner=owner, group=group, mode=mode, atomic=atomic)
async def _close(self) -> None:
pass