mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 08:26:53 +08:00
fix SMB Usage
This commit is contained in:
@@ -516,18 +516,10 @@ class SMB(StorageBase, metaclass=Singleton):
|
||||
return False
|
||||
|
||||
def link(self, fileitem: schemas.FileItem, target_file: Path) -> bool:
|
||||
"""
|
||||
硬链接文件(SMB不支持,返回False)
|
||||
"""
|
||||
logger.warn("【SMB】不支持硬链接操作")
|
||||
return False
|
||||
pass
|
||||
|
||||
def softlink(self, fileitem: schemas.FileItem, target_file: Path) -> bool:
|
||||
"""
|
||||
软链接文件(SMB不支持,返回False)
|
||||
"""
|
||||
logger.warn("【SMB】不支持软链接操作")
|
||||
return False
|
||||
pass
|
||||
|
||||
def usage(self) -> Optional[schemas.StorageUsage]:
|
||||
"""
|
||||
@@ -535,34 +527,15 @@ class SMB(StorageBase, metaclass=Singleton):
|
||||
"""
|
||||
try:
|
||||
self._check_connection()
|
||||
volume_stat = smbclient.stat_volume(self._server_path)
|
||||
return schemas.StorageUsage(
|
||||
total=volume_stat.total_size,
|
||||
available=volume_stat.caller_available_size
|
||||
)
|
||||
|
||||
# 获取磁盘使用情况
|
||||
try:
|
||||
stat_result = smbclient.stat(self._server_path)
|
||||
|
||||
if hasattr(stat_result, 'f_frsize') and hasattr(stat_result, 'f_blocks'):
|
||||
block_size = stat_result.f_frsize
|
||||
total_blocks = stat_result.f_blocks
|
||||
free_blocks = stat_result.f_bavail
|
||||
|
||||
total = total_blocks * block_size
|
||||
available = free_blocks * block_size
|
||||
|
||||
return schemas.StorageUsage(
|
||||
total=total,
|
||||
available=available
|
||||
)
|
||||
except Exception as e:
|
||||
logger.debug(f"【SMB】获取磁盘使用情况失败: {e}")
|
||||
# 返回默认值
|
||||
return schemas.StorageUsage(
|
||||
total=0,
|
||||
available=0
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"【SMB】获取存储使用情况失败: {e}")
|
||||
|
||||
return None
|
||||
return None
|
||||
|
||||
def __del__(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user