From 5e3739780ff3b308a78a88c0d588b91568b711ab Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 6 Dec 2023 03:24:56 +0200 Subject: [PATCH] fs: system: cleanup reflink (#235) * fs: system: cleanup reflink Per https://github.com/iterative/dvc-objects/pull/234/files#r1416499169 * Update system.py * Update system.py --- src/dvc_objects/fs/system.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/dvc_objects/fs/system.py b/src/dvc_objects/fs/system.py index 9a17c19..68bb5f4 100644 --- a/src/dvc_objects/fs/system.py +++ b/src/dvc_objects/fs/system.py @@ -1,3 +1,4 @@ +import ctypes import errno import logging import os @@ -39,8 +40,6 @@ def symlink(source: "AnyFSPath", link_name: "AnyFSPath") -> None: @functools.lru_cache(maxsize=1) def _clonefile(): - import ctypes - def _cdll(name): return ctypes.CDLL(name, use_errno=True) @@ -67,15 +66,14 @@ def _cdll(name): "'clonefile' not supported by the standard library", ) + clonefile.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int] + clonefile.restype = ctypes.c_int + return clonefile def _reflink_darwin(src: "AnyFSPath", dst: "AnyFSPath") -> None: - import ctypes - clonefile = _clonefile() - clonefile.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int] - clonefile.restype = ctypes.c_int ret = clonefile( ctypes.c_char_p(os.fsencode(src)),