Get aggregated statistics
()
| 13272 | demonstrations. Deletion order: |
| 13273 | 1. Delete ragnar.db database file |
| 13274 | 2. Delete entire data/ folder |
| 13275 | 3. Delete entire Ragnar/ repository |
| 13276 | |
| 13277 | Security: Requires confirmation token to prevent accidental triggering |
| 13278 | """ |
| 13279 | try: |
| 13280 | # Get confirmation from request |
| 13281 | data = request.get_json() or {} |
| 13282 | confirmation = data.get('confirmation', '') |
| 13283 | shutdown_after = data.get('shutdown', False) |
| 13284 | |
| 13285 | # Require explicit confirmation to prevent accidental wipes |
| 13286 | if confirmation != 'ERASE_ALL_DATA': |
| 13287 | logger.warning("Kill switch triggered without proper confirmation") |
| 13288 | return jsonify({ |
| 13289 | 'success': False, |
| 13290 | 'error': 'Invalid confirmation token. Use "ERASE_ALL_DATA" to confirm.' |
| 13291 | }), 403 |
| 13292 | |
| 13293 | logger.critical("=" * 80) |
| 13294 | logger.critical("KILL SWITCH ACTIVATED - INITIATING COMPLETE DATA ERASURE") |
| 13295 | logger.critical("=" * 80) |
| 13296 | |
| 13297 | results = { |
| 13298 | 'database_deleted': False, |
| 13299 | 'data_folder_deleted': False, |
| 13300 | 'repository_deleted': False, |
| 13301 | 'shutdown_scheduled': False, |
| 13302 | 'errors': [] |
| 13303 | } |
| 13304 | |
| 13305 | # Get the Ragnar directory path |
| 13306 | ragnar_dir = shared_data.currentdir |
| 13307 | home_dir = os.path.expanduser('~') |
| 13308 | ragnar_home_path = os.path.join(home_dir, 'Ragnar') |
| 13309 | |
| 13310 | # Use home path if it exists, otherwise use current directory |
| 13311 | if os.path.exists(ragnar_home_path): |
| 13312 | ragnar_dir = ragnar_home_path |
| 13313 | |
| 13314 | logger.critical(f"Target Ragnar directory: {ragnar_dir}") |
| 13315 | |
| 13316 | # STEP 1: Delete ragnar.db database file |
| 13317 | try: |
| 13318 | db_path = os.path.join(ragnar_dir, 'data', 'ragnar.db') |
| 13319 | logger.critical(f"Step 1/3: Deleting database file: {db_path}") |
| 13320 | |
| 13321 | if os.path.isfile(db_path): |
| 13322 | os.remove(db_path) |
| 13323 | logger.critical(f"✓ Deleted: {db_path}") |
| 13324 | results['database_deleted'] = True |
| 13325 | else: |
| 13326 | logger.warning(f"Database file not found: {db_path}") |
| 13327 | results['database_deleted'] = True # Consider it success if file doesn't exist |
| 13328 | |
| 13329 | except Exception as e: |
| 13330 | error_msg = f"Error deleting database file: {str(e)}" |
| 13331 | logger.error(error_msg) |