mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
lib.FileContext.put(): Change param mode type str -> int
Don't pass mode as a string to put(). Given the multitunde of possible string representations for numbers, some understood by int(string, 0) and some not, there's too much room for passing strings which are unparseable, or worse, prone to be parsed wrongly. However, pass mode down to _put() as a string for convenience, because that's what most _put() implementations will need to use. If they don't, converting to int is easy from the one defined string format. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
64e9fbff59
commit
fe3508036e
3 changed files with 5 additions and 4 deletions
|
|
@ -31,4 +31,4 @@ class CmdCopy(Cmd): # export
|
||||||
return url
|
return url
|
||||||
return self.app.distro_info(url)
|
return self.app.distro_info(url)
|
||||||
await copy(__expand(args.src), __expand(args.dst),
|
await copy(__expand(args.src), __expand(args.dst),
|
||||||
owner=args.owner, group=args.group, mode=args.mode)
|
owner=args.owner, group=args.group, mode=int(args.mode, 0))
|
||||||
|
|
|
||||||
|
|
@ -102,11 +102,12 @@ class FileContext(abc.ABC):
|
||||||
title: str = None,
|
title: str = None,
|
||||||
owner: str|None = None,
|
owner: str|None = None,
|
||||||
group: str|None = None,
|
group: str|None = None,
|
||||||
mode: str|None = None,
|
mode: int|None = None,
|
||||||
atomic: bool = False
|
atomic: bool = False
|
||||||
) -> Result:
|
) -> Result:
|
||||||
|
mode_str = None if mode is None else oct(mode).replace('0o', '0')
|
||||||
return await self._put(path, content, wd=wd, throw=throw, verbose=verbose,
|
return await self._put(path, content, wd=wd, throw=throw, verbose=verbose,
|
||||||
title=title, owner=owner, group=group, mode=mode, atomic=atomic)
|
title=title, owner=owner, group=group, mode=mode_str, atomic=atomic)
|
||||||
|
|
||||||
async def _close(self) -> None:
|
async def _close(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ async def run_sudo(cmd: list[str], *args, interactive: bool=True, ec: ExecContex
|
||||||
ec = Local(interactive=interactive)
|
ec = Local(interactive=interactive)
|
||||||
return await ec.sudo(cmd, *args, **kwargs)
|
return await ec.sudo(cmd, *args, **kwargs)
|
||||||
|
|
||||||
async def copy(src_uri: str, dst_uri: str, owner: str|None=None, group: str|None=None, mode: str|None=None, throw=True) -> Exception|str:
|
async def copy(src_uri: str, dst_uri: str, owner: str|None=None, group: str|None=None, mode: int|None=None, throw=True) -> Exception|str:
|
||||||
from .ExecContext import ExecContext
|
from .ExecContext import ExecContext
|
||||||
src: ExecContext|None = None
|
src: ExecContext|None = None
|
||||||
dst: ExecContext|None = None
|
dst: ExecContext|None = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue