fix: temp
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
mol
2023-09-06 10:13:57 +08:00
parent 1d7dbeb749
commit a2d324fb07
2 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,11 @@
# 更新笔记 # 更新笔记
## v1.2.1
_Bug fixes_
- 修复没有 temp 文件夹的 bug
## v1.2.0 ## v1.2.0
_Bug fixes_ _Bug fixes_

View File

@ -3,6 +3,7 @@ import shutil
def save_file(name, data): def save_file(name, data):
temp_path = os.path.join(os.path.dirname(__file__), 'temp') temp_path = os.path.join(os.path.dirname(__file__), 'temp')
check_dir(temp_path)
with open(os.path.join(temp_path, name), 'wb') as code: with open(os.path.join(temp_path, name), 'wb') as code:
code.write(data) code.write(data)
@ -15,6 +16,7 @@ def remove_file(path):
def clear_dir(): def clear_dir():
temp_path = os.path.join(os.path.dirname(__file__), 'temp') temp_path = os.path.join(os.path.dirname(__file__), 'temp')
check_dir(temp_path)
flag = True flag = True
for files in os.listdir(temp_path): for files in os.listdir(temp_path):
path = os.path.join(temp_path, files) path = os.path.join(temp_path, files)
@ -26,4 +28,9 @@ def clear_dir():
print('Info: temp dir is cleared') print('Info: temp dir is cleared')
def check_dir(path):
is_exists = os.path.exists(path)
if not(is_exists):
os.mkdir(path.encode('utf-8'))
return