fix lot of thing
This commit is contained in:
@@ -68,8 +68,37 @@ class LinkageSwitchingBase(ScrollArea):
|
||||
fileDate = data.get("created_at", data.get("date", ""))
|
||||
fileSize = data.get("size", 0)
|
||||
|
||||
# 构建符合Cloudreve V4 API要求的正确URI格式
|
||||
if filePath == "/" or filePath == "":
|
||||
# 根目录情况
|
||||
full_uri = f"cloudreve://my/{fileName}"
|
||||
else:
|
||||
# 子目录情况,确保正确拼接路径
|
||||
# 清理路径,避免重复的斜杠和前缀
|
||||
clean_path = filePath.lstrip("/")
|
||||
# 确保路径中不包含cloudreve://my前缀
|
||||
clean_path = clean_path.replace("cloudreve://my/", "")
|
||||
full_uri = f"cloudreve://my/{clean_path}/{fileName}"
|
||||
|
||||
# 确保路径格式正确,移除重复的前缀
|
||||
full_uri = full_uri.replace("cloudreve://my/cloudreve://my", "cloudreve://my")
|
||||
|
||||
# 更健壮地处理重复文件名的情况
|
||||
# 分割路径并去重
|
||||
path_parts = full_uri.split('/')
|
||||
if len(path_parts) > 1:
|
||||
# 检查最后一个部分是否是文件名
|
||||
if path_parts[-1] == fileName:
|
||||
# 检查倒数第二个部分是否也是文件名
|
||||
if len(path_parts) > 2 and path_parts[-2] == fileName:
|
||||
# 移除重复的文件名部分
|
||||
path_parts.pop(-2)
|
||||
full_uri = '/'.join(path_parts)
|
||||
|
||||
logger.debug(f"构建文件URI: {full_uri}")
|
||||
|
||||
fileCard = FileCard(
|
||||
fileId,
|
||||
full_uri, # 传递完整的URI而不是文件ID
|
||||
fileName,
|
||||
fileType,
|
||||
filePath,
|
||||
|
||||
Reference in New Issue
Block a user