diff --git a/cli_launcher.py b/cli_launcher.py index e89d7422..0d381c8c 100644 --- a/cli_launcher.py +++ b/cli_launcher.py @@ -713,6 +713,7 @@ def _build_update_rsync_excludes(update_buttons: bool, update_img: bool, update_ if not update_redis_cache: excludes.append("--exclude=core/redis_cache.py") excludes.append("--exclude=modules") + excludes.append("--exclude=static/web_uploads") return excludes @@ -902,12 +903,18 @@ def clean_project_dir_safe(update_buttons=False, update_img=False, update_redis_ os.path.join(PROJECT_DIR, "handlers", "texts.py"), os.path.join(PROJECT_DIR, ".git"), os.path.join(PROJECT_DIR, "modules"), + os.path.join(PROJECT_DIR, "static"), + os.path.join(PROJECT_DIR, "static", "web_uploads"), ]) for root, dirs, files in os.walk(os.path.join(PROJECT_DIR, "modules")): for name in dirs + files: preserved_paths.add(os.path.join(root, name)) + for root, dirs, files in os.walk(os.path.join(PROJECT_DIR, "static", "web_uploads")): + for name in dirs + files: + preserved_paths.add(os.path.join(root, name)) + if not update_buttons: preserved_paths.add(os.path.join(PROJECT_DIR, "handlers", "buttons.py")) @@ -939,12 +946,17 @@ def clean_project_dir_safe(update_buttons=False, update_img=False, update_redis_ os.path.join(PROJECT_DIR, "handlers"), os.path.join(PROJECT_DIR, "img"), os.path.join(PROJECT_DIR, "modules"), + os.path.join(PROJECT_DIR, "static"), + os.path.join(PROJECT_DIR, "static", "web_uploads"), ]: continue if os.path.abspath(dir_path).startswith(os.path.join(PROJECT_DIR, "modules") + os.sep): continue + if os.path.abspath(dir_path).startswith(os.path.join(PROJECT_DIR, "static", "web_uploads") + os.sep): + continue + try: os.rmdir(dir_path) except Exception: diff --git a/database/users.py b/database/users.py index cd1a172c..f2773863 100644 --- a/database/users.py +++ b/database/users.py @@ -323,12 +323,26 @@ async def delete_user_data(session: AsyncSession, legacy_user_ref: int): ) await session.execute(delete(GiftUsage).where(GiftUsage.user_id == uid)) await session.execute(delete(Gift).where(Gift.sender_user_id == uid)) - await session.execute(update(Gift).where(Gift.recipient_user_id == uid).values(recipient_user_id=None)) + await session.execute( + update(Gift).where(Gift.recipient_user_id == uid).values(recipient_user_id=None, recipient_tg_id=None) + ) + if u.tg_id is not None: + await session.execute( + update(Gift).where(Gift.recipient_tg_id == u.tg_id).values(recipient_tg_id=None) + ) + await session.execute( + update(Gift).where(Gift.sender_tg_id == u.tg_id).values(sender_tg_id=None) + ) + await session.execute( + update(Payment).where(Payment.tg_id == u.tg_id).values(tg_id=None) + ) await session.execute(delete(Payment).where(Payment.user_id == uid)) await session.execute( delete(Referral).where(or_(Referral.referrer_user_id == uid, Referral.referred_user_id == uid)) ) await session.execute(delete(CouponUsage).where(CouponUsage.user_id == uid)) + if u.tg_id is not None: + await session.execute(update(Key).where(Key.tg_id == u.tg_id).values(tg_id=None)) await delete_key(session, uid) await session.execute( delete(TemporaryData).where(