Skip to content

Commit 7dcb20b

Browse files
committed
INTEGRITY: Remove custom recursive path split function.
1 parent e86f982 commit 7dcb20b

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

compute_hash.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,11 @@ def punycode_need_encode(orig):
132132
return True
133133
return False
134134

135-
136-
def split_path_recursive(path):
137-
parts = []
138-
while True:
139-
head, tail = os.path.split(path)
140-
if tail:
141-
parts.insert(0, tail)
142-
path = head
143-
else:
144-
if head:
145-
parts.insert(0, head)
146-
break
147-
return parts
148-
149135
def encode_path_components(filepath):
150136
"""
151137
Puny encodes all separate components of filepath
152138
"""
153-
parts = split_path_recursive(filepath)
139+
parts = [i for i in filepath.split(os.sep) if i ]
154140
encoded_parts = [encode_punycode(p) if punycode_need_encode(p) else p for p in parts]
155141
return os.path.join(*encoded_parts)
156142

@@ -733,7 +719,7 @@ def create_dat_file(hash_of_dirs, path, checksum_size=0):
733719
file.write("game (\n")
734720
for filename, (hashes, size, size_r, size_rd, timestamp) in hash_of_dir.items():
735721
filename = encode_path_components(filename)
736-
data = f"name \"{filename}\" size {size} size-r {size_r} size-rd {size_rd} timestamp {timestamp}"
722+
data = f"name '{filename}' size {size} size-r {size_r} size-rd {size_rd} modification-time {timestamp}"
737723
for key, value in hashes:
738724
data += f" {key} {value}"
739725

0 commit comments

Comments
 (0)