fix progress step

This commit is contained in:
jxxghp
2025-08-24 16:33:44 +08:00
parent 2285befebb
commit 8fac8c5307
6 changed files with 17 additions and 16 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ def transfer_process(path: str) -> Callable[[int | float], None]:
""" """
传输进度回调 传输进度回调
""" """
pbar = tqdm(total=100, desc="整理进度", unit="%") pbar = tqdm(total=100, desc="整理进度")
progress = ProgressHelper(path) progress = ProgressHelper(path)
progress.start() progress.start()
+4 -1
View File
@@ -45,6 +45,9 @@ class AliPan(StorageBase, metaclass=WeakSingleton):
# 基础url # 基础url
base_url = "https://openapi.alipan.com" base_url = "https://openapi.alipan.com"
# 文件块大小,默认10MB
chunk_size = 10 * 1024 * 1024
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._auth_state = {} self._auth_state = {}
@@ -724,7 +727,7 @@ class AliPan(StorageBase, metaclass=WeakSingleton):
downloaded_size = 0 downloaded_size = 0
with open(local_path, "wb") as f: with open(local_path, "wb") as f:
for chunk in r.iter_content(chunk_size=8192): for chunk in r.iter_content(chunk_size=self.chunk_size):
if chunk: if chunk:
f.write(chunk) f.write(chunk)
downloaded_size += len(chunk) downloaded_size += len(chunk)
+1 -3
View File
@@ -31,9 +31,7 @@ class Alist(StorageBase, metaclass=WeakSingleton):
"move": "移动", "move": "移动",
} }
# 文件块大小,默认1MB # 快照检查目录修改时间
chunk_size = 1024 * 1024
snapshot_check_folder_modtime = settings.OPENLIST_SNAPSHOT_CHECK_FOLDER_MODTIME snapshot_check_folder_modtime = settings.OPENLIST_SNAPSHOT_CHECK_FOLDER_MODTIME
def __init__(self): def __init__(self):
+2 -2
View File
@@ -25,8 +25,8 @@ class LocalStorage(StorageBase):
"softlink": "软链接" "softlink": "软链接"
} }
# 文件块大小,默认1MB # 文件块大小,默认100MB
chunk_size = 1024 * 1024 chunk_size = 100 * 1024 * 1024
def init_storage(self): def init_storage(self):
""" """
+5 -8
View File
@@ -39,6 +39,9 @@ class SMB(StorageBase, metaclass=WeakSingleton):
"copy": "复制", "copy": "复制",
} }
# 文件块大小,默认100MB
chunk_size = 100 * 1024 * 1024
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._connected = False self._connected = False
@@ -433,12 +436,9 @@ class SMB(StorageBase, metaclass=WeakSingleton):
# 使用更高效的文件传输方式 # 使用更高效的文件传输方式
with smbclient.open_file(smb_path, mode="rb") as src_file: with smbclient.open_file(smb_path, mode="rb") as src_file:
with open(local_path, "wb") as dst_file: with open(local_path, "wb") as dst_file:
# 使用更大的缓冲区提高性能
buffer_size = 1024 * 1024 # 1MB
downloaded_size = 0 downloaded_size = 0
while True: while True:
chunk = src_file.read(buffer_size) chunk = src_file.read(self.chunk_size)
if not chunk: if not chunk:
break break
dst_file.write(chunk) dst_file.write(chunk)
@@ -483,12 +483,9 @@ class SMB(StorageBase, metaclass=WeakSingleton):
# 使用更高效的文件传输方式 # 使用更高效的文件传输方式
with open(path, "rb") as src_file: with open(path, "rb") as src_file:
with smbclient.open_file(smb_path, mode="wb") as dst_file: with smbclient.open_file(smb_path, mode="wb") as dst_file:
# 使用更大的缓冲区提高性能
buffer_size = 1024 * 1024 # 1MB
uploaded_size = 0 uploaded_size = 0
while True: while True:
chunk = src_file.read(buffer_size) chunk = src_file.read(self.chunk_size)
if not chunk: if not chunk:
break break
dst_file.write(chunk) dst_file.write(chunk)
+4 -1
View File
@@ -43,6 +43,9 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
# 基础url # 基础url
base_url = "https://proapi.115.com" base_url = "https://proapi.115.com"
# 文件块大小,默认10MB
chunk_size = 10 * 1024 * 1024
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._auth_state = {} self._auth_state = {}
@@ -610,7 +613,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
downloaded_size = 0 downloaded_size = 0
with open(local_path, "wb") as f: with open(local_path, "wb") as f:
for chunk in r.iter_content(chunk_size=8192): for chunk in r.iter_content(chunk_size=self.chunk_size):
if chunk: if chunk:
f.write(chunk) f.write(chunk)
downloaded_size += len(chunk) downloaded_size += len(chunk)