Skip to content

Commit

Permalink
delete existed temp files in case
Browse files Browse the repository at this point in the history
Fallen-Breath committed Aug 17, 2021

Verified

This commit was signed with the committer’s verified signature.
Fallen-Breath Fallen_Breath
1 parent 033945f commit 50c69db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion permanent_backup/__init__.py
Original file line number Diff line number Diff line change
@@ -122,7 +122,10 @@ def filter_ignore(path, files):
return [file for file in files if file == 'session.lock' and config.ignore_session_lock]
touch_backup_folder()
for world in config.world_names:
shutil.copytree(os.path.join(config.server_path, world), os.path.join(config.backup_path, world), ignore=filter_ignore)
target_path = os.path.join(config.backup_path, world)
if os.path.isdir(target_path):
shutil.rmtree(target_path)
shutil.copytree(os.path.join(config.server_path, world), target_path, ignore=filter_ignore)
if not auto_save_on:
source.get_server().execute('save-on')
auto_save_on = True
@@ -152,6 +155,7 @@ def filter_ignore(path, files):
info_message(source, '备份§a完成§r,耗时{}秒'.format(round(time.time() - start_time, 1)), broadcast=True)
except Exception as e:
info_message(source, '备份§a失败§r,错误代码{}'.format(e), broadcast=True)
source.get_server().logger.exception('创建备份失败')
finally:
creating_backup.release()
if config.turn_off_auto_save and not auto_save_on:

0 comments on commit 50c69db

Please # to comment.