fix: Update backup timestamp format in force update configuration

- Changed the variable name from 'time' to 'current_time' for clarity.
- Updated the backup file naming to use the current timestamp correctly, ensuring accurate backup creation.
This commit is contained in:
yeongpin 2025-04-07 10:53:06 +08:00
parent 386ffa4568
commit 63fe39f2c1

View File

@ -4,6 +4,7 @@ import configparser
from colorama import Fore, Style
from utils import get_user_documents_path, get_default_chrome_path, get_linux_cursor_path
import shutil
import datetime
EMOJI = {
"INFO": "",
@ -269,13 +270,12 @@ def force_update_config(translator=None):
try:
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
config_file = os.path.join(config_dir, "config.ini")
datetime = datetime.datetime
time = datetime.now()
current_time = datetime.datetime.now()
if os.path.exists(config_file):
try:
# create backup
backup_file = f"{config_file}.bak.{time.strftime('%Y%m%d_%H%M%S')}"
backup_file = f"{config_file}.bak.{current_time.strftime('%Y%m%d_%H%M%S')}"
shutil.copy2(config_file, backup_file)
if translator:
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.backup_created', path=backup_file) if translator else f'Backup created: {backup_file}'}{Style.RESET_ALL}")