use_subvolumes: ConfigFeature = ConfigFeature.disabled,
tools: Path = Path("/"),
sandbox: Sequence[PathString] = (),
-) -> None:
+) -> Path:
if use_subvolumes == ConfigFeature.enabled and not find_binary("btrfs", root=tools):
die("Subvolumes requested but the btrfs command was not found")
die(f"Subvolumes requested but {path} is not located on a btrfs filesystem")
path.mkdir()
- return
+ return path
if use_subvolumes != ConfigFeature.disabled and find_binary("btrfs", root=tools) is not None:
result = run(["btrfs", "subvolume", "create", path],
if result != 0:
path.mkdir()
+ return path
+
@contextlib.contextmanager
def preserve_target_directories_stat(src: Path, dst: Path) -> Iterator[None]:
use_subvolumes: ConfigFeature = ConfigFeature.disabled,
tools: Path = Path("/"),
sandbox: Sequence[PathString] = (),
-) -> None:
+) -> Path:
subvolume = (use_subvolumes == ConfigFeature.enabled or
use_subvolumes == ConfigFeature.auto and find_binary("btrfs", root=tools) is not None)
else contextlib.nullcontext()
):
run(copy, sandbox=sandbox)
- return
+ return dst
# btrfs can't snapshot to an existing directory so make sure the destination does not exist.
if dst.exists():
):
run(copy, sandbox=sandbox)
+ return dst
+
def rmtree(*paths: Path, sandbox: Sequence[PathString] = ()) -> None:
if paths:
use_subvolumes: ConfigFeature = ConfigFeature.disabled,
tools: Path = Path("/"),
sandbox: Sequence[PathString] = (),
-) -> None:
+) -> Path:
if src == dst:
- return
+ return dst
if dst.is_dir():
dst = dst / src.name
copy_tree(src, dst, use_subvolumes=use_subvolumes, tools=tools, sandbox=sandbox)
rmtree(src, sandbox=sandbox)
+
+ return dst