Add fast reflink
This commit is contained in:
parent
704a9d9968
commit
e13548fbdc
|
@ -36,6 +36,14 @@ config["default"] = {
|
|||
"linkMethod": "hardlink"
|
||||
}
|
||||
config.read(p(sp,os.path.splitext(os.path.basename(s))[0] + ".ini"))
|
||||
if config["default"]["linkMethod"] == "reflink":
|
||||
fancyReflink = False
|
||||
try:
|
||||
from reflink import reflink
|
||||
fancyReflink = True
|
||||
except:
|
||||
print("python3-reflink not installed, using shell for reflink (slow)\n")
|
||||
|
||||
|
||||
def filterDd(text):
|
||||
while text[-1] in ['"',"'"," ",os.path.sep]: text = text[:-1]
|
||||
|
@ -100,13 +108,17 @@ def linkFile(src,dst,method = False):
|
|||
return
|
||||
|
||||
if method == "reflink":
|
||||
if os.name == "nt":
|
||||
global btrfsdll
|
||||
if not btrfsdll: btrfsdll = ctypes.cdll.LoadLibrary("shellbtrfs.dll")
|
||||
btrfsdll.ReflinkCopyW(0,0,'"' +src+ '" "' +dst+ '"',1)
|
||||
if fancyReflink == False:
|
||||
if os.name == "nt":
|
||||
global btrfsdll
|
||||
if not btrfsdll: btrfsdll = ctypes.cdll.LoadLibrary("shellbtrfs.dll")
|
||||
btrfsdll.ReflinkCopyW(0,0,'"' +src+ '" "' +dst+ '"',1)
|
||||
else:
|
||||
subprocess.call(["cp","-n","--reflink=always",src,dst])
|
||||
return
|
||||
else:
|
||||
subprocess.call(["cp","-n","--reflink=always",src,dst])
|
||||
return
|
||||
reflink(src,dst)
|
||||
return
|
||||
|
||||
raise Exception("uml", "invalid link method")
|
||||
|
||||
|
|
Loading…
Reference in New Issue