[Enhance] Add an option about file hash pre-calc

- Add an option to disable song file hash pre-calculation
This commit is contained in:
Lost-MSth
2023-01-14 18:32:53 +08:00
parent af03a48134
commit 9c90d6ef89
5 changed files with 21 additions and 13 deletions

View File

@@ -13,13 +13,11 @@ def md5(code: str) -> str:
def get_file_md5(file_path: str) -> str:
'''计算文件MD5'''
if not os.path.isfile(file_path):
return None
'''计算文件MD5,假设是文件'''
myhash = hashlib.md5()
with open(file_path, 'rb') as f:
while True:
b = f.read(8096)
b = f.read(8192)
if not b:
break
myhash.update(b)