From c5d6ba09f22b53fd015b09b4fee926bf92b2fb22 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 7 Feb 2023 21:25:26 +0000 Subject: [PATCH] Check if Cookie file for profile already exists during auth add Fixes #16. --- devine/commands/auth.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devine/commands/auth.py b/devine/commands/auth.py index 2ec1544..3dbe419 100644 --- a/devine/commands/auth.py +++ b/devine/commands/auth.py @@ -1,4 +1,5 @@ import logging +import sys import tkinter.filedialog from collections import defaultdict from pathlib import Path @@ -239,6 +240,9 @@ def add(ctx: click.Context, profile: str, service: str, cookie: Optional[str] = if cookie: final_path = (config.directories.cookies / service / profile).with_suffix(".txt") final_path.parent.mkdir(parents=True, exist_ok=True) + if final_path.exists(): + log.error(f"A Cookie file for the Profile {profile} on {service} already exists.") + sys.exit(1) cookie = cookie.rename(final_path) log.info(f"Moved Cookie file to: {cookie}")