add: Command.receive_from_stream

This commit is contained in:
timeshifter
2021-12-02 15:23:32 +01:00
parent f28df3e4c6
commit 359a6a99a8
+7 -4
View File
@@ -274,10 +274,9 @@ class ZFS:
# -u File system that is associated with the received stream is not mounted.
if not isinstance(pool, Pool):
raise TypeError("Can only receive into pools.")
# TODO use internal functions
check_output(
Command.receive_from_stream(
[config.ZFS, "receive", "-d", "-F", "-u", pool.name],
stdin=stream.stdout,
stream,
)
@classmethod
@@ -489,7 +488,7 @@ class Snapshot:
class Command:
@staticmethod
def run(cmdline: list[str]):
def run(cmdline: list[str]) -> None:
call(cmdline)
@staticmethod
@@ -498,6 +497,10 @@ class Command:
cmdline = [cmdline]
return check_output(cmdline).strip().decode()
@staticmethod
def receive_from_stream(cmdline: str | list[str], stream: Popen) -> None:
check_output(cmdline, stdin=stream.stdout)
def verify_running_as_root():
if getuid() > 0: