Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
fix(download): 🐛 fix avatar bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnzhiZhang committed Jun 16, 2022
1 parent 320e557 commit 67c17cb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def main(self):
self.avatar_base_name = self.name if self.name else name
self.avatar_base_name = self.avatar_base_name.replace('.', '_')
self.avatar_name = self.avatar_base_name + ext
else:
self.avatar_name = ''

# 计算路径
self.file_base_name = os.path.basename(self.zip_file_path)
Expand All @@ -69,8 +71,9 @@ def main(self):
self.unzip()

try:
with open(self.avatar_path, 'wb') as f:
f.write(Requester.get(self.avatar_url).content)
if self.avatar_name:
with open(self.avatar_path, 'wb') as f:
f.write(Requester.get(self.avatar_url).content)
download_urls = self.get_download_urls()
except:
self.clean_file()
Expand Down Expand Up @@ -209,7 +212,7 @@ def write_mmc_files(self):
# 写入 instance.cfg
instance_cfg_path = os.path.join(self.dir_path, 'instance.cfg')
content = 'InstanceType=OneSix\n'
if self.avatar_base_name:
if self.avatar_name:
content += f'iconKey={self.avatar_base_name}\n'
with open(instance_cfg_path, 'w', encoding='utf-8') as f:
f.write(content)
Expand Down

0 comments on commit 67c17cb

Please sign in to comment.