Further reduce the maximum length of vcard file name #51

This commit is contained in:
KnugiHK
2023-06-16 01:46:27 +08:00
parent 41f45fb07c
commit c366e656af
2 changed files with 2 additions and 2 deletions

View File

@@ -546,7 +546,7 @@ def vcard(db, data):
for index, row in enumerate(rows):
media_name = row["media_name"] if row["media_name"] is not None else ""
file_name = "".join(x for x in media_name if x.isalnum())
file_name = file_name.encode('utf-8')[:251].decode('utf-8', 'ignore')
file_name = file_name.encode('utf-8')[:230].decode('utf-8', 'ignore')
file_path = os.path.join(base, f"{file_name}.vcf")
if not os.path.isfile(file_path):
with open(file_path, "w", encoding="utf-8") as f:

View File

@@ -248,7 +248,7 @@ def vcard(db, data):
Path(base).mkdir(parents=True, exist_ok=True)
for index, content in enumerate(contents):
file_name = "".join(x for x in content["ZVCARDNAME"] if x.isalnum())
file_name = file_name.encode('utf-8')[:251].decode('utf-8', 'ignore')
file_name = file_name.encode('utf-8')[:230].decode('utf-8', 'ignore')
file_path = os.path.join(base, f"{file_name}.vcf")
if not os.path.isfile(file_path):
with open(file_path, "w", encoding="utf-8") as f: