From d76a1a1038c5e688d082c35697a824be8130451c Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 16 Mar 2026 08:46:22 -0400 Subject: [PATCH] Preserve existing configuration during reinstallation When reinstalling LBRY Downloader, the setup script now: - Checks if config.yaml exists in ~/Documents/lbry-downloads/ - If found, asks user if they want to use existing config - If yes, skips all configuration prompts and preserves channels/settings - If no, proceeds with normal interactive setup This prevents users from having to re-enter all their channels and settings every time they reinstall or update the tool. Fixes #2 - Config is no longer overwritten on reinstall. --- setup.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index c34f136..11f1540 100755 --- a/setup.py +++ b/setup.py @@ -589,19 +589,64 @@ def run_setup() -> None: print_error("Failed to install Python dependencies") sys.exit(1) - # Get configuration from user - download_location = get_download_location() - channels = get_channels() - download_limit = get_download_limit() + # Check for existing configuration + default_download_location = "~/Documents/lbry-downloads" + config_path = Path(default_download_location).expanduser() / "config.yaml" - # Create config file - print_header("Creating Configuration") - config_content = create_config(download_location, channels, download_limit) + if config_path.exists(): + print_header("Existing Configuration Found") + print_info(f"Found existing config: {config_path}") + print_info("This will preserve your channels and settings") - config_path = Path(download_location).expanduser() / "config.yaml" - config_path.parent.mkdir(parents=True, exist_ok=True) - config_path.write_text(config_content) - print_success(f"Created configuration: {config_path}") + response = input("Use existing configuration? (Y/n): ").strip().lower() + if response != "n": + print_success("Using existing configuration") + download_location = default_download_location + # Ensure necessary directories exist + Path(download_location).expanduser().mkdir(parents=True, exist_ok=True) + (Path(download_location).expanduser() / "state").mkdir(exist_ok=True) + (Path(download_location).expanduser() / "channels").mkdir(exist_ok=True) + # Store config_path for final message + config_path = Path(download_location).expanduser() / "config.yaml" + else: + # User wants to reconfigure + download_location = get_download_location() + channels = get_channels() + download_limit = get_download_limit() + + # Create config file + print_header("Creating Configuration") + config_content = create_config(download_location, channels, download_limit) + + config_path = Path(download_location).expanduser() / "config.yaml" + config_path.parent.mkdir(parents=True, exist_ok=True) + config_path.write_text(config_content) + print_success(f"Created configuration: {config_path}") + + # Create necessary directories + (config_path.parent / "state").mkdir(exist_ok=True) + (config_path.parent / "channels").mkdir(exist_ok=True) + print_success("Created directory structure") + else: + # No existing config, proceed with normal setup + # Get configuration from user + download_location = get_download_location() + channels = get_channels() + download_limit = get_download_limit() + + # Create config file + print_header("Creating Configuration") + config_content = create_config(download_location, channels, download_limit) + + config_path = Path(download_location).expanduser() / "config.yaml" + config_path.parent.mkdir(parents=True, exist_ok=True) + config_path.write_text(config_content) + print_success(f"Created configuration: {config_path}") + + # Create necessary directories + (config_path.parent / "state").mkdir(exist_ok=True) + (config_path.parent / "channels").mkdir(exist_ok=True) + print_success("Created directory structure") # Create necessary directories (config_path.parent / "state").mkdir(exist_ok=True)