refactor(string): split utilities by responsibility

This commit is contained in:
jxxghp
2026-08-15 08:03:55 +08:00
parent a2117bafc8
commit 96118e73e7
99 changed files with 1608 additions and 1424 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ from app.schemas.exception import StorageQueryError
from app.schemas.types import StorageSchema
from app.adapters.network.http import RequestUtils
from app.foundation.singleton import WeakSingleton
from app.domain.string import StringUtils
from app.foundation import temporal as time_tools
lock = threading.Lock()
@@ -305,7 +305,7 @@ class AliPan(StorageBase, metaclass=WeakSingleton):
name=fileinfo.get("name"),
basename=fileinfo.get("name"),
size=fileinfo.get("size"),
modify_time=StringUtils.str_to_timestamp(fileinfo.get("updated_at")),
modify_time=time_tools.parse_timestamp(fileinfo.get("updated_at")),
drive_id=fileinfo.get("drive_id"),
)
else:
@@ -319,7 +319,7 @@ class AliPan(StorageBase, metaclass=WeakSingleton):
basename=Path(fileinfo.get("name")).stem,
size=fileinfo.get("size"),
extension=fileinfo.get("file_extension"),
modify_time=StringUtils.str_to_timestamp(fileinfo.get("updated_at")),
modify_time=time_tools.parse_timestamp(fileinfo.get("updated_at")),
thumbnail=fileinfo.get("thumbnail"),
drive_id=fileinfo.get("drive_id"),
)
+3 -3
View File
@@ -12,7 +12,7 @@ from app.runtime.log import logger
from app.modules.filemanager.storages import StorageBase, transfer_process
from app.schemas.exception import StorageQueryError
from app.schemas.types import StorageSchema
from app.domain.string import StringUtils
from app.foundation import temporal as time_tools
from app.adapters.system.host import SystemUtils
_MAX_FOLDER_LOCKS = 4096
@@ -127,7 +127,7 @@ class Rclone(StorageBase):
path=f"{parent}{item.get('Name')}" + "/",
name=item.get("Name"),
basename=item.get("Name"),
modify_time=StringUtils.str_to_timestamp(item.get("ModTime"))
modify_time=time_tools.parse_timestamp(item.get("ModTime"))
)
else:
return schemas.FileItem(
@@ -138,7 +138,7 @@ class Rclone(StorageBase):
basename=Path(item.get("Name")).stem,
extension=Path(item.get("Name")).suffix[1:],
size=item.get("Size"),
modify_time=StringUtils.str_to_timestamp(item.get("ModTime"))
modify_time=time_tools.parse_timestamp(item.get("ModTime"))
)
@staticmethod
+3 -3
View File
@@ -20,7 +20,7 @@ from app.modules.filemanager.storages import transfer_process
from app.schemas.exception import StorageQueryError
from app.schemas.types import StorageSchema
from app.foundation.singleton import WeakSingleton
from app.domain.string import StringUtils
from app.foundation import size as size_tools
from app.runtime.rate import QpsRateLimiter, RateStats
@@ -690,7 +690,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
if info_resp["file_category"] == "1"
else None,
pickcode=info_resp["pick_code"],
size=StringUtils.num_filesize(info_resp["size"])
size=size_tools.parse_size(info_resp["size"])
if info_resp["file_category"] == "1"
else None,
modify_time=info_resp["utime"],
@@ -742,7 +742,7 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
# 初始化进度条
logger.info(
f"【115】开始上传: {local_path} -> {target_path},分片大小:{StringUtils.str_filesize(part_size)}"
f"【115】开始上传: {local_path} -> {target_path},分片大小:{size_tools.format_compact_size(part_size)}"
)
progress_callback = transfer_process(local_path.as_posix())