ã/b_path style
This commit is contained in:
@@ -61,16 +61,16 @@ def ScanVolume(volume_letter: str):
|
||||
|
||||
name = entry
|
||||
|
||||
# 分离盘符并去除开头的 \
|
||||
# 分离盘符并去除开头和结尾的 \
|
||||
_, relative_path = os.path.splitdrive(full_path)
|
||||
relative_path = relative_path.lstrip("\\")
|
||||
relative_path = relative_path.lstrip("\\").rstrip("\\")
|
||||
|
||||
# 如果是文件夹,Path 字段结尾加 '\\'
|
||||
if is_dir and not relative_path.endswith("\\"):
|
||||
relative_path += "\\"
|
||||
# 如果是目录,结尾加 /
|
||||
if os.path.isdir(full_path) and not relative_path.endswith("/"):
|
||||
relative_path += "/"
|
||||
|
||||
# ✅ 关键修改点:将所有 \ 替换为 \\
|
||||
relative_path = relative_path.replace("\\", "\\\\")
|
||||
# 替换所有 \ -> /
|
||||
relative_path = relative_path.replace("\\", "/")
|
||||
|
||||
path_hash = GenerateHash(relative_path)
|
||||
|
||||
@@ -80,10 +80,10 @@ def ScanVolume(volume_letter: str):
|
||||
|
||||
parent_path = os.path.dirname(full_path)
|
||||
_, parent_relative_path = os.path.splitdrive(parent_path)
|
||||
parent_relative_path = parent_relative_path.lstrip("\\").rstrip("\\") # 去除首尾 \
|
||||
if os.path.isdir(parent_path) and not parent_relative_path.endswith("\\"): # 如果是目录,补 \
|
||||
parent_relative_path += "\\"
|
||||
parent_relative_path = parent_relative_path.replace("\\", "\\\\") # 转换为双反斜杠 \\
|
||||
parent_relative_path = parent_relative_path.lstrip("\\").rstrip("\\")
|
||||
if os.path.isdir(parent_path) and not parent_relative_path.endswith("/"):
|
||||
parent_relative_path += "/"
|
||||
parent_relative_path = parent_relative_path.replace("\\", "/")
|
||||
|
||||
parent_id = path_to_id.get(parent_relative_path, 0)
|
||||
|
||||
|
Reference in New Issue
Block a user