From 2bd6456f458909c70eef36668d964424c9d521c2 Mon Sep 17 00:00:00 2001 From: rambros Date: Wed, 25 Feb 2026 03:28:53 +0530 Subject: [PATCH] major V2 update --- src/core/base.py | 12 ++++++++++-- src/core/state.py | 10 +++++----- src/fluxer/clone_server.py | 4 ++-- src/fluxer/emoji_stickers.py | 2 +- src/fluxer/roles_permissions.py | 2 +- src/stoat/clone_server.py | 4 ++-- src/stoat/emoji_stickers.py | 2 +- src/stoat/roles_permissions.py | 2 +- src/ui/app.py | 2 +- 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/core/base.py b/src/core/base.py index 819295b..a71acab 100644 --- a/src/core/base.py +++ b/src/core/base.py @@ -15,9 +15,17 @@ class MigrationContext: def __init__(self, config: AppConfig, target_platform: str = "fluxer"): self.config = config self.target_platform = target_platform + + # Use the target server/community ID for state file naming so each + # target server gets its own independent migration history. + if target_platform == "stoat": + server_id = config.stoat_server_id + else: + server_id = config.fluxer_community_id + self.state = MigrationState( - state_file=f"{target_platform}.state.json", - messages_file=f"{target_platform}.messages.json" + state_file=f"{server_id}.state.json", + messages_file=f"{server_id}.messages.json" ) self.discord_reader = DiscordReader( diff --git a/src/core/state.py b/src/core/state.py index b72117d..768ca29 100644 --- a/src/core/state.py +++ b/src/core/state.py @@ -5,7 +5,7 @@ from typing import Dict, Any class MigrationState: """Manages persistence of the migration state to allow resumability.""" - def __init__(self, state_file: str | Path = "fluxer.state.json", messages_file: str | Path = "fluxer.messages.json"): + def __init__(self, state_file: str | Path = "default.state.json", messages_file: str | Path = "default.messages.json"): self.state_file = Path(state_file) self.messages_file = Path(messages_file) @@ -30,7 +30,7 @@ class MigrationState: migrated_state = False migrated_messages = False - # 1. Load primary fluxer.state.json + # 1. Load primary state file if self.state_file.exists(): with open(self.state_file, "r", encoding="utf-8") as f: data = json.load(f) @@ -41,12 +41,12 @@ class MigrationState: self.sticker_map = data.get("stickers", {}) self.audit_log_channel = data.get("audit_log_channel") - # Check for legacy messages in fluxer.state.json + # Check for legacy messages in state file if "messages" in data or "last_message_timestamps" in data: self.message_map = data.get("messages", {}) self.last_message_ids = data.get("last_message_ids", {}) self.last_message_timestamps = data.get("last_message_timestamps", {}) - migrated_messages = True # We found legacy data, we should write it out to fluxer.messages.json later + migrated_messages = True # We found legacy data, we should write it out to messages file later # Legacy Migration: Move role_, emoji_, sticker_ from channel_map to dedicated maps legacy_keys = list(self.channel_map.keys()) @@ -64,7 +64,7 @@ class MigrationState: self.sticker_map[discord_id] = self.channel_map.pop(k) migrated_state = True - # 2. Load separate fluxer.messages.json (overrides legacy fluxer.state.json) + # 2. Load separate messages file (overrides legacy state file messages) if self.messages_file.exists(): with open(self.messages_file, "r", encoding="utf-8") as f: msg_data = json.load(f) diff --git a/src/fluxer/clone_server.py b/src/fluxer/clone_server.py index 6b599bb..0efd6f4 100644 --- a/src/fluxer/clone_server.py +++ b/src/fluxer/clone_server.py @@ -8,8 +8,8 @@ logger = logging.getLogger(__name__) async def sync_channel_state(context: MigrationContext): """ - Scans Fluxer for channels matching Discord names and updates fluxer.state.json mappings. - This prevents duplicate creation when the fluxer.state.json is empty but channels exist in Fluxer. + Scans Fluxer for channels matching Discord names and updates state file mappings. + This prevents duplicate creation when the state file is empty but channels exist in Fluxer. """ categories = await context.discord_reader.get_categories() channels = await context.discord_reader.get_channels() diff --git a/src/fluxer/emoji_stickers.py b/src/fluxer/emoji_stickers.py index 6be9a44..036d6c0 100644 --- a/src/fluxer/emoji_stickers.py +++ b/src/fluxer/emoji_stickers.py @@ -8,7 +8,7 @@ logger = logging.getLogger(__name__) async def sync_assets_state(context: MigrationContext): """ - Scans Fluxer for emojis and stickers matching Discord names and updates fluxer.state.json mappings. + Scans Fluxer for emojis and stickers matching Discord names and updates state file mappings. """ discord_emojis = await context.discord_reader.get_emojis() discord_stickers = await context.discord_reader.get_stickers() diff --git a/src/fluxer/roles_permissions.py b/src/fluxer/roles_permissions.py index 99c8a9c..4d06d39 100644 --- a/src/fluxer/roles_permissions.py +++ b/src/fluxer/roles_permissions.py @@ -8,7 +8,7 @@ logger = logging.getLogger(__name__) async def sync_roles_state(context: MigrationContext): """ - Scans Fluxer for roles matching Discord names and updates fluxer.state.json mappings. + Scans Fluxer for roles matching Discord names and updates state file mappings. """ discord_roles = await context.discord_reader.get_roles() fluxer_roles = await context.fluxer_writer.client.get_guild_roles(context.config.fluxer_community_id) diff --git a/src/stoat/clone_server.py b/src/stoat/clone_server.py index 85baf8d..22a9c4c 100644 --- a/src/stoat/clone_server.py +++ b/src/stoat/clone_server.py @@ -9,8 +9,8 @@ logger = logging.getLogger(__name__) async def sync_channel_state(context: MigrationContext): """ - Scans Stoat for channels matching Discord names and updates stoat.state.json mappings. - This prevents duplicate creation when the stoat.state.json is empty but channels exist in Stoat. + Scans Stoat for channels matching Discord names and updates state file mappings. + This prevents duplicate creation when the state file is empty but channels exist in Stoat. """ categories = await context.discord_reader.get_categories() channels = await context.discord_reader.get_channels() diff --git a/src/stoat/emoji_stickers.py b/src/stoat/emoji_stickers.py index 486f5a9..c47e24c 100644 --- a/src/stoat/emoji_stickers.py +++ b/src/stoat/emoji_stickers.py @@ -8,7 +8,7 @@ logger = logging.getLogger(__name__) async def sync_assets_state(context: MigrationContext): """ - Scans Stoat for emojis matching Discord names and updates stoat.state.json mappings. + Scans Stoat for emojis matching Discord names and updates state file mappings. """ discord_emojis = await context.discord_reader.get_emojis() # Stickers not supported on Stoat based on current library investigation diff --git a/src/stoat/roles_permissions.py b/src/stoat/roles_permissions.py index 41aa3d4..6f074aa 100644 --- a/src/stoat/roles_permissions.py +++ b/src/stoat/roles_permissions.py @@ -8,7 +8,7 @@ logger = logging.getLogger(__name__) async def sync_roles_state(context: MigrationContext): """ - Scans Stoat for roles matching Discord names and updates stoat.state.json mappings. + Scans Stoat for roles matching Discord names and updates state file mappings. """ discord_roles = await context.discord_reader.get_roles() server = await context.stoat_writer._get_server() diff --git a/src/ui/app.py b/src/ui/app.py index aa2d327..d49cb17 100644 --- a/src/ui/app.py +++ b/src/ui/app.py @@ -514,7 +514,7 @@ class MigrationCLI: force = False if cached_count > 0: - console.print(f"[yellow]\u26a0 {cached_count}/{all_ids_len} item(s) already in fluxer.state.json cache.[/yellow]") + console.print(f"[yellow]\u26a0 {cached_count}/{all_ids_len} item(s) already in state cache.[/yellow]") # End of table consolidated section, back to standard flow logic. console.print("[bold green](Y) Continue with only missing items[/bold green]")