implement one click update,sync option
This commit is contained in:
parent
bc500641bf
commit
cbfeb8e51e
1 changed files with 70 additions and 55 deletions
|
|
@ -173,7 +173,7 @@ class DiscoReaperCLI:
|
||||||
finally:
|
finally:
|
||||||
await self.engine.close_connections()
|
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."""
|
"""Option 2: Backup Channels structure and all message history."""
|
||||||
if not self.tokens_valid: return
|
if not self.tokens_valid: return
|
||||||
try:
|
try:
|
||||||
|
|
@ -200,6 +200,20 @@ class DiscoReaperCLI:
|
||||||
console.print("[yellow]No text/news channels found to backup.[/yellow]")
|
console.print("[yellow]No text/news channels found to backup.[/yellow]")
|
||||||
return
|
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]")
|
console.print(f"\n[bold]Select Channels to Backup ({len(eligible_channels)} total):[/bold]")
|
||||||
|
|
||||||
# Identify duplicate names to show categories for them
|
# Identify duplicate names to show categories for them
|
||||||
|
|
@ -231,7 +245,6 @@ class DiscoReaperCLI:
|
||||||
if selection_input.upper() == "B":
|
if selection_input.upper() == "B":
|
||||||
return
|
return
|
||||||
|
|
||||||
selected_channels = []
|
|
||||||
if selection_input.upper() == "A":
|
if selection_input.upper() == "A":
|
||||||
selected_channels = eligible_channels
|
selected_channels = eligible_channels
|
||||||
else:
|
else:
|
||||||
|
|
@ -254,8 +267,9 @@ class DiscoReaperCLI:
|
||||||
any_found = True
|
any_found = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if force_overwrite is None:
|
||||||
force_overwrite = False
|
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("\n[bold yellow]Existing backup(s) found for some selected channels.[/bold yellow]")
|
||||||
console.print("(Y) Update & Sync Backup")
|
console.print("(Y) Update & Sync Backup")
|
||||||
console.print("(F) [bold red]Force Overwrite Backup[/bold red]")
|
console.print("(F) [bold red]Force Overwrite Backup[/bold red]")
|
||||||
|
|
@ -304,10 +318,11 @@ class DiscoReaperCLI:
|
||||||
await self.engine.close_connections()
|
await self.engine.close_connections()
|
||||||
|
|
||||||
async def sync_backup(self):
|
async def sync_backup(self):
|
||||||
"""Option 3: Update & Sync Backup (Runs a full pass but overwrites where needed)."""
|
"""Option 3: Update & Sync Backup (Automated incremental sync for existing backups)."""
|
||||||
console.print("[yellow]Syncing backup... (Re-validating all data)[/yellow]")
|
console.print("[yellow]Syncing backup... (Updating existing data)[/yellow]")
|
||||||
await self.backup_server_profile()
|
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):
|
async def edit_configuration(self):
|
||||||
# reuse or implement simplified version of edit_configuration from app.py
|
# reuse or implement simplified version of edit_configuration from app.py
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue