Skip to content

Commit

Permalink
Only remove old files once
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye authored Jan 2, 2024
1 parent 12a9dd1 commit 90b5bfc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions submanager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def generate_check_config(locations, uuid, host, path, save_path):
with open(save_path, "w", encoding="utf-8") as file:
file.write(config_content)


def update_client_config(locations, providers, credentials):
def remove_old_client_config():
directory_path = os.path.join(DIRECTORY_PATH, "conf")
if os.path.exists(directory_path):
shutil.rmtree(directory_path)
Expand All @@ -163,6 +162,7 @@ def update_client_config(locations, providers, credentials):
"Old client config files removed",
)

def update_client_config(locations, providers, credentials):
for client in credentials:
name, uuid, host, path = (
client["name"],
Expand Down Expand Up @@ -236,7 +236,7 @@ def update_nginx_config(credentials):
)


def update(nginx=False):
def update(nginx=False, remove_old_file=False):
try:
locations = get_location_ip()
providers = get_provider_ip()
Expand All @@ -252,6 +252,9 @@ def update(nginx=False):
if nginx:
update_nginx_config(credentials)

if remove_old_file:
remove_old_client_config()

update_client_config(locations, providers, credentials)

except Exception as e:
Expand All @@ -260,7 +263,7 @@ def update(nginx=False):


if __name__ == "__main__":
update(nginx=True)
update(nginx=True, remove_old_file=True)

schedule.every().day.at("00:00").do(update)
schedule.every().day.at("06:00").do(update)
Expand Down

0 comments on commit 90b5bfc

Please sign in to comment.