Skip to content

Commit

Permalink
ulwgl_util.py: Do not use copyfile_reflink if the root and local ar…
Browse files Browse the repository at this point in the history
…e not

on the same filesystem.
  • Loading branch information
loathingKernel committed Mar 1, 2024
1 parent d887de4 commit 4507878
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ULWGL/ulwgl_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def force_rename(src: Path, dst: Path): # noqa: D103
src.rename(dst)


def same_fs(file1: Path, file2: Path) -> bool: # noqa: D103
dev1 = file1.stat().st_dev
dev2 = file2.stat().st_dev
return dev1 == dev2


def setup_runtime(root: Path, json: Dict[str, Any]) -> None: # noqa: D103
# Access the 'runtime_platform' value
runtime_platform_value: str = json["ulwgl"]["versions"]["runtime_platform"]
Expand Down Expand Up @@ -191,7 +197,7 @@ def _install_ulwgl(
"""
cp: Callable[Path, Path] = None

if hasattr(os, "copy_file_range"):
if same_fs(root, local) and hasattr(os, "copy_file_range"):
log.debug("CoW filesystem detected")
cp = copyfile_reflink
else:
Expand Down Expand Up @@ -255,7 +261,7 @@ def _update_ulwgl(
"""
cp: Callable[Path, Path] = None

if hasattr(os, "copy_file_range"):
if same_fs(root, local) and hasattr(os, "copy_file_range"):
log.debug("CoW filesystem detected")
cp = copyfile_reflink
else:
Expand Down

0 comments on commit 4507878

Please sign in to comment.