implement one click update,sync option

This commit is contained in:
rambros 2026-03-01 18:25:06 +05:30
parent bc500641bf
commit cbfeb8e51e

View file

@ -173,7 +173,7 @@ class DiscoReaperCLI:
finally:
await self.engine.close_connections()
async def backup_messages(self):
async def backup_messages(self, force_overwrite=None, skip_found_prompt=False, auto_sync_existing=False):
"""Option 2: Backup Channels structure and all message history."""
if not self.tokens_valid: return
try:
@ -200,6 +200,20 @@ class DiscoReaperCLI:
console.print("[yellow]No text/news channels found to backup.[/yellow]")
return
selected_channels = []
if auto_sync_existing:
selected_channels = [
c for c in eligible_channels
if (self.exporter.export_path / "message_backup" / f"{c.id}.json").exists()
]
if not selected_channels:
console.print("[yellow]No existing backups found to sync.[/yellow]")
return
# In auto-sync mode, we always use sync (force_overwrite=False) and skip prompts
force_overwrite = False
skip_found_prompt = True
else:
console.print(f"\n[bold]Select Channels to Backup ({len(eligible_channels)} total):[/bold]")
# Identify duplicate names to show categories for them
@ -231,7 +245,6 @@ class DiscoReaperCLI:
if selection_input.upper() == "B":
return
selected_channels = []
if selection_input.upper() == "A":
selected_channels = eligible_channels
else:
@ -254,8 +267,9 @@ class DiscoReaperCLI:
any_found = True
break
if force_overwrite is None:
force_overwrite = False
if any_found:
if any_found and not skip_found_prompt:
console.print("\n[bold yellow]Existing backup(s) found for some selected channels.[/bold yellow]")
console.print("(Y) Update & Sync Backup")
console.print("(F) [bold red]Force Overwrite Backup[/bold red]")
@ -304,10 +318,11 @@ class DiscoReaperCLI:
await self.engine.close_connections()
async def sync_backup(self):
"""Option 3: Update & Sync Backup (Runs a full pass but overwrites where needed)."""
console.print("[yellow]Syncing backup... (Re-validating all data)[/yellow]")
"""Option 3: Update & Sync Backup (Automated incremental sync for existing backups)."""
console.print("[yellow]Syncing backup... (Updating existing data)[/yellow]")
await self.backup_server_profile()
await self.backup_messages()
# Automatically select and sync existing backups
await self.backup_messages(auto_sync_existing=True)
async def edit_configuration(self):
# reuse or implement simplified version of edit_configuration from app.py