ã/b_path style
This commit is contained in:
20
fake_main.py
20
fake_main.py
@@ -3,20 +3,20 @@ from files_utils.files_sort import GetSortFragments
|
||||
|
||||
fragment_lists = {}
|
||||
test_files = [
|
||||
r"CloudMusic\AGA - MIZU.mp3",
|
||||
r"CloudMusic\AGA - 一.mp3",
|
||||
r"CloudMusic\Aaron Zigman - Main Title.mp3",
|
||||
r"CloudMusic\Anson Seabra - Keep Your Head Up Princess.mp3",
|
||||
r"CloudMusic\Anthony Keyrouz,Romy Wave - Something Just Like This (feat. Romy Wave).mp3",
|
||||
r"CloudMusic\Ava Max - Sweet but Psycho.mp3",
|
||||
r"CloudMusic\Cecilia Cheung - Turn Into Fireworks and Fall for You.mp3",
|
||||
r"CloudMusic\Color Music Choir - Something Just Like This (Live).mp3"
|
||||
r"CloudMusic/AGA - MIZU.mp3",
|
||||
r"CloudMusic/AGA - 一.mp3",
|
||||
r"CloudMusic/Aaron Zigman - Main Title.mp3",
|
||||
r"CloudMusic/Anson Seabra - Keep Your Head Up Princess.mp3",
|
||||
r"CloudMusic/Anthony Keyrouz,Romy Wave - Something Just Like This (feat. Romy Wave).mp3",
|
||||
r"CloudMusic/Ava Max - Sweet but Psycho.mp3",
|
||||
r"CloudMusic/Cecilia Cheung - Turn Into Fireworks and Fall for You.mp3",
|
||||
r"CloudMusic/Color Music Choir - Something Just Like This (Live).mp3"
|
||||
]
|
||||
|
||||
sort_fragments = GetSortFragments(db_path="./src/db_ntfs_info.db", files_list=test_files)
|
||||
for item in sort_fragments:
|
||||
extent_count = item['extent_count']
|
||||
if extent_count == 1:
|
||||
CopySingleFragmentFiles(item, target_path=r"Z:\test_files")
|
||||
CopySingleFragmentFiles(item, target_path=r"Z:/test_files")
|
||||
elif extent_count > 1:
|
||||
CopyMultiFragmentFiles(item, fragment_lists=fragment_lists, target_path=r"Z:\test_files")
|
||||
CopyMultiFragmentFiles(item, fragment_lists=fragment_lists, target_path=r"Z:/test_files")
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -145,7 +145,7 @@ def GetSubPathsByParentID(
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_folder_path = "pictures"
|
||||
test_folder_path = "pictures/"
|
||||
parent_id_test = GetFolderID(test_folder_path)
|
||||
# node_data = GetNodeFragmentsByParentID(parent_id_test)
|
||||
path_data = GetSubPathsByParentID(parent_id_test)
|
||||
|
Reference in New Issue
Block a user